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

NotNullViolation on PostgreSQL migration of populated table with a notnull field #675

Open
zejdad opened this issue Oct 31, 2021 · 0 comments

Comments

@zejdad
Copy link

zejdad commented Oct 31, 2021

Hi,

db.define_table('tablename, Field('fieldname, notnull=True)) triggers psycopg2.errors.NotNullViolation: column "fieldname__tmp" of relation "tablename" contains null values on PostgreSQL migrations when there is already some data in the table. It gives sense because py4web creates notnull fieldname__tmp with null values (supposed to be replaced by fieldname data in the next step).

Setting default to something else than DEFAULT serves as a workaround.

On PostgreSQL I would suggest setting notnull=False for temporary fields (*__tmp) even if the original field is notnull=True, unless there is a non-null default value specified.

David

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