Skip to content

Commit

Permalink
Fix query building edgecases, to support Wagtail on workers-dbms
Browse files Browse the repository at this point in the history
  • Loading branch information
G4brym committed Nov 10, 2024
1 parent c7ba34c commit 103941a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 9 additions & 0 deletions django_dbms/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,20 @@ class DatabaseFeatures(SQLiteDatabaseFeatures):

class DatabaseOperations(SQLiteDatabaseOperations):
pragma_foreign_keys = None
cast_data_types = {
"DateField": "TEXT",
"DateTimeField": "TEXT",
"PositiveIntegerField": "INTEGER",
}

def _quote_columns(self, sql):
"""
Ensure column names are properly quoted and aliased to avoid collisions.
Also handles CAST statements properly for NULL values.
"""
# First, fix any problematic CAST statements with None
sql = sql.replace('None(', '(')

parsed = sqlparse.parse(sql)
if not parsed:
return sql # Unable to parse, return original SQL
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "django-cf"
version = "0.0.16"
version = "0.0.17"
authors = [
{ name="Gabriel Massadas" },
]
Expand Down

0 comments on commit 103941a

Please sign in to comment.