Fix Postgres 500s on days and entries by dropping SQLite rowid.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
9d5befdde9
commit
ea38528ecf
5 files changed
+11
-5
No files matched your search
@@ -9,6 +9,7 @@ import os
|
||||
import re
|
||||
|
||||
_INSERT_OR_IGNORE = re.compile(r"INSERT\s+OR\s+IGNORE\s+INTO", re.IGNORECASE)
|
||||
_ROWID_COL = re.compile(r"\.rowid\b", re.IGNORECASE)
|
||||
_ON_CONFLICT_PAREN = re.compile(r"ON\s+CONFLICT\s*\(", re.IGNORECASE)
|
||||
_PRAGMA_TABLE = re.compile(
|
||||
r"^\s*PRAGMA\s+table_info\(\s*['\"]?(\w+)['\"]?\s*\)\s*;?\s*$",
|
||||
@@ -101,6 +102,7 @@ def replace_placeholders(sql: str) -> str:
|
||||
def adapt_sql(sql: str) -> str:
|
||||
"""Make a SQLite-shaped statement runnable on PostgreSQL."""
|
||||
sql = sqlite_schema_to_postgres(sql)
|
||||
sql = _ROWID_COL.sub(".id", sql)
|
||||
sql = _ON_CONFLICT_PAREN.sub("ON CONFLICT (", sql)
|
||||
used_ignore = bool(_INSERT_OR_IGNORE.search(sql))
|
||||
sql = _INSERT_OR_IGNORE.sub("INSERT INTO", sql)
|
||||
|
||||
Reference in new issue
Block a user