From 6d59dd6c438c2e86ad10e0203e1734e71dfd4e2e Mon Sep 17 00:00:00 2001 From: Charles Leifer Date: Thu, 8 Aug 2024 10:14:57 -0500 Subject: [PATCH] Reverts 09a1f78ca and instead ensures double quotes are escaped. Double quotes should be used for identifiers - it's a quirk that Sqlite accepts them for strings as well, but in the event we encounter them we should escape them to try to keep valid Python. Refs #2909 --- playhouse/reflection.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/playhouse/reflection.py b/playhouse/reflection.py index ff26f6a2f..c534b04a2 100644 --- a/playhouse/reflection.py +++ b/playhouse/reflection.py @@ -92,7 +92,8 @@ def get_field_parameters(self): if self.primary_key and not issubclass(self.field_class, AutoField): params['primary_key'] = True if self.default is not None: - params['constraints'] = '[SQL(\'DEFAULT %s\')]' % self.default + params['constraints'] = '[SQL("DEFAULT %s")]' % \ + self.default.replace('"', '\\"') # Handle ForeignKeyField-specific attributes. if self.is_foreign_key():