Skip to content

match_pk comparing DB column name with form field name #146

Description

@grgghrn

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions