-
-
Notifications
You must be signed in to change notification settings - Fork 31.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refs #33308 -- Added psycopg_any.sql.quote() hook.
- Loading branch information
Showing
3 changed files
with
16 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,17 @@ | ||
from psycopg2 import errors, extensions # NOQA | ||
from psycopg2 import errors, extensions, sql # NOQA | ||
from psycopg2.extras import DateRange, DateTimeRange, DateTimeTZRange, Inet # NOQA | ||
from psycopg2.extras import Json as Jsonb # NOQA | ||
from psycopg2.extras import NumericRange, Range # NOQA | ||
|
||
RANGE_TYPES = (DateRange, DateTimeRange, DateTimeTZRange, NumericRange) | ||
|
||
|
||
def _quote(value, connection=None): | ||
adapted = extensions.adapt(value) | ||
if hasattr(adapted, "encoding"): | ||
adapted.encoding = "utf8" | ||
# getquoted() returns a quoted bytestring of the adapted value. | ||
return adapted.getquoted().decode() | ||
|
||
|
||
sql.quote = _quote |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters