coleifer / peewee

a small, expressive orm -- supports postgresql, mysql, sqlite and cockroachdb
http://docs.peewee-orm.com/
MIT License
11.06k stars 1.37k forks source link

pwiz generates invalid Python code when creating BareField instances #2909

Closed fortysix2ahead closed 2 months ago

fortysix2ahead commented 2 months ago

When used on the Adobe Lightroom sqlite db, pwiz will generate lines of code like the following, which is not valid Python code (single vs. double quotation marks):

state = BareField(constraints=[SQL("DEFAULT "master"")], null=True)
...
state = BareField(constraints=[SQL("DEFAULT "needs_binary"")], null=True)
...
binary_type = BareField(column_name='binaryType', constraints=[SQL("DEFAULT "original"")], null=True)
coleifer commented 2 months ago

Thanks, should be fixed now.

xnny commented 1 month ago

But my default value might be something like this:

DEFAULT '{}'::jsonb

After an update, I can no longer generate the demapped model using pwiz.

Changing double quotes to single quotes directly makes me incompatible with the old table structure.

coleifer commented 1 month ago

Oh wait, you're right @xnny - it should be preferring single quotes and escaping double quotes. Let me re-fix this.

coleifer commented 1 month ago

That should be fixed now.

xnny commented 1 month ago

Thank you very much.