-
Notifications
You must be signed in to change notification settings - Fork 262
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
Allow to opt out from special naming when fieldname ends with _id #355
Comments
OK, can you show me the schema and the code generated from it? I'd like to understand the problem better. |
@agronholm it should be obvious when you compare the outcome of the testcases test_named_foreign_key_constraints and test_named_foreign_key_constraints_with_noidsuffix (added with the PR #356) NORMAL
WITH --noidsuffix
the FK on field container_id is usually named container (the code strips _id) but I want it to be named like the source table simple_containers The fact that I prefix my tables with "t_" is mostly irrelevant for my request. With that convention in place, I can simply expect all FKs to start with "t_" as class members, which has some ergonomical benefits. |
Things to check first
Feature description
The code part that will handle FKs on field names that end with _id is simply driving me nuts because it can lead to inconsitent naming on parent and child tables.
sqlacodegen/src/sqlacodegen/generators.py
Line 1059 in 9925f10
Please add a n option to opt-out from it
Use case
I have all my tables prefix with t_ in my db so that they are renamed like
t_child -> TChild
t_parent -> TParent
if I now have a field parent_id on the child table, I will end up with
"parent" as FK on the child table
and
"t_child" as FK on the parent table
which is inconsitent IMO
The text was updated successfully, but these errors were encountered: