Skip to content

Commit

Permalink
tweak to use regex to fix function call
Browse files Browse the repository at this point in the history
  • Loading branch information
Mause committed Dec 12, 2023
1 parent bca2d99 commit a719a8d
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions duckdb_engine/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ def get_check_constraints(
raise NotImplementedError() from e


PG_GET_CONSTRAINTDEF = "pg_get_constraintdef(cons.oid)"
PG_GET_CONSTRAINTDEF_NEW = "pg_get_constraintdef(cons.oid, true)"
PG_GET_CONSTRAINTDEF = re.compile(r"pg_get_constraintdef\(([a-z\.]+)\)", re.I)


class ConnectionWrapper:
Expand Down Expand Up @@ -141,7 +140,9 @@ def execute(
parameters: Optional[Tuple] = None,
context: Optional[Any] = None,
) -> None:
statement = statement.replace(PG_GET_CONSTRAINTDEF, PG_GET_CONSTRAINTDEF_NEW)
statement = PG_GET_CONSTRAINTDEF.sub(
lambda match: f"pg_get_constraintdef({match[1]}, true)", statement
)
try:
if statement.lower() == "commit": # this is largely for ipython-sql
self.__c.commit()
Expand Down

0 comments on commit a719a8d

Please sign in to comment.