Add constraint naming convention configuration option#197
Add constraint naming convention configuration option#197leonarduschen wants to merge 12 commits intoagronholm:masterfrom
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.
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.
How would users know what to enter here, based on this?
There was a problem hiding this comment.
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
SQLAlchemybut not insqlacodegen:- Using custom function as naming convention token
- Using the constraint object name as key instead of mnemonic (e.g.,
PrimaryKeyConstraintcannot 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