-
Notifications
You must be signed in to change notification settings - Fork 257
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add constraint naming convention configuration option #197
base: master
Are you sure you want to change the base?
Add constraint naming convention configuration option #197
Conversation
FYI, I'm planning one last big refactoring before the final release (one which should resolve the issue of code duplication) and it will probably clash with this PR. |
Right, I'm actually working on 2 additional issues, details outlined in #193 (comment) Those issues are only relevant when using these 2 types of tokens:
I was thinking of doing everything in one go in this PR, but if you're going to do a big refactoring then perhaps I should just fix those in subsequent PRs? For now we can add a note in the docs that those tokens cannot be used. Let me know what you think. |
a75ccae
to
53de15d
Compare
I've opened #200 to address the design choice of config file support which we probably need for this. |
"--conv", | ||
nargs="*", | ||
help='constraint naming conventions in "key=template" format \ | ||
e.g., --conv "pk=pk_%%(table_name)s" "uq=uq_%%(table_name)s_%%(column_0_name)s"', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added the option to add the naming convention via command line on top of config file (which hasn't been added yet)
I was thinking, for each config option, we can go like this:
- Check if it is available as command line arg
- If not, check if it is available in config file
- If not, fall back to default value
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How would users know what to enter here, based on this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well we assume users interested in using this option are already familiar with SQLAlchemy's constraint naming convention feature from https://docs.sqlalchemy.org/en/14/core/constraints.html#configuring-constraint-naming-conventions or https://alembic.sqlalchemy.org/en/latest/naming.html. In this case, the help
string above would enough in my opinion.
We can also add more details in README:
- Link to SQLAlchemy/Alembic docs above
- Maybe also basic info about constraint naming convention and its usage in SQLAlchemy, basically summarizing the docs above
- Things supported in
SQLAlchemy
but not insqlacodegen
:- Using custom function as naming convention token
- Using the constraint object name as key instead of mnemonic (e.g.,
PrimaryKeyConstraint
cannot be used as key, must usepk
)
8b194c7
to
e60f480
Compare
I've addressed the 2 issues I mentioned earlier #193 (comment) - ready for review now |
Closes #193