Skip to content
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

match_pk comparing DB column name with form field name #146

Open
grgghrn opened this issue Mar 26, 2019 · 0 comments
Open

match_pk comparing DB column name with form field name #146

grgghrn opened this issue Mar 26, 2019 · 0 comments

Comments

@grgghrn
Copy link

grgghrn commented Mar 26, 2019

If I have a model with a field declared (note upper case "ID"):
id = db.Column('ID', db.Integer, primary_key=True)

And an associated ModelForm with a field:
id = IntegerField()

When I post back the form (unchanged, for testing), it tries to recreate the row because it's not matching up to the existing row here:

data_val = data.get(col.name)

Because the field is 'id' and the Column was initialized upper case as 'ID' (Of course I can make it lower case in this situation and it works)

So I'm just learning alchemy & wtforms - but this seems to rely on an unspoken naming convention (or at least consistency through the stack) - naming the PK field the same as the db column. This is not otherwise a requirement and took me a bit to figure out what was happening.

So my question is, can/should this be looking at the names of the fields instead of the internal column name? Or is this by design and I'm just missing something.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant