Skip to content

Commit

Permalink
Added get_dialect func to have ability to pass json_serializer (#451
Browse files Browse the repository at this point in the history
)
  • Loading branch information
Gr1N authored and vir-mir committed May 9, 2018
1 parent d5b59d8 commit 45babe7
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions aiopg/sa/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,22 @@ def _exec_default(self, default):
return default.arg


_dialect = PGDialect_psycopg2(json_serializer=json.dumps,
json_deserializer=lambda x: x)

_dialect.statement_compiler = APGCompiler_psycopg2
_dialect.implicit_returning = True
_dialect.supports_native_enum = True
_dialect.supports_smallserial = True # 9.2+
_dialect._backslash_escapes = False
_dialect.supports_sane_multi_rowcount = True # psycopg 2.0.9+
_dialect._has_native_hstore = True
def get_dialect(json_serializer=json.dumps, json_deserializer=lambda x: x):
dialect = PGDialect_psycopg2(json_serializer=json_serializer,
json_deserializer=json_deserializer)

dialect.statement_compiler = APGCompiler_psycopg2
dialect.implicit_returning = True
dialect.supports_native_enum = True
dialect.supports_smallserial = True # 9.2+
dialect._backslash_escapes = False
dialect.supports_sane_multi_rowcount = True # psycopg 2.0.9+
dialect._has_native_hstore = True

return dialect


_dialect = get_dialect()


def create_engine(dsn=None, *, minsize=1, maxsize=10, loop=None,
Expand Down

0 comments on commit 45babe7

Please sign in to comment.