Skip to content

Commit 635d92e

Browse files
committed
black
1 parent 100baab commit 635d92e

File tree

2 files changed

+27
-18
lines changed

2 files changed

+27
-18
lines changed

src/gino/crud.py

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -802,39 +802,46 @@ async def _execute_and_fetch(conn, query):
802802
lookup_conds = [
803803
c == last_row_id
804804
if c is table._autoincrement_column
805-
else c == _cast_json(
806-
c, compiled_params.get(key_getter(c), None))
805+
else c
806+
== _cast_json(c, compiled_params.get(key_getter(c), None))
807807
for c in table.primary_key
808808
]
809809
else:
810810
lookup_conds = [
811-
c == _cast_json(
812-
c, compiled_params.get(key_getter(c), None))
811+
c == _cast_json(c, compiled_params.get(key_getter(c), None))
813812
for c in table.columns
814813
]
815-
query = sa.select(table.columns).where(
816-
sa.and_(*lookup_conds)).execution_options(**execution_opts)
814+
query = (
815+
sa.select(table.columns)
816+
.where(sa.and_(*lookup_conds))
817+
.execution_options(**execution_opts)
818+
)
817819
row = await conn.first(query)
818820
elif context.isupdate:
819821
if context.get_affected_rows() == 0:
820822
raise NoSuchRowError()
821823
table = context.compiled.statement.table
822824
if len(table.primary_key) > 0:
823825
lookup_conds = [
824-
c == _cast_json(
825-
c, item.__values__[
826-
item._column_name_map.invert_get(c.name)])
826+
c
827+
== _cast_json(
828+
c, item.__values__[item._column_name_map.invert_get(c.name)]
829+
)
827830
for c in table.primary_key
828831
]
829832
else:
830833
lookup_conds = [
831-
c == _cast_json(
832-
c, item.__values__[
833-
item._column_name_map.invert_get(c.name)])
834+
c
835+
== _cast_json(
836+
c, item.__values__[item._column_name_map.invert_get(c.name)]
837+
)
834838
for c in table.columns
835839
]
836-
query = sa.select(table.columns).where(
837-
sa.and_(*lookup_conds)).execution_options(**execution_opts)
840+
query = (
841+
sa.select(table.columns)
842+
.where(sa.and_(*lookup_conds))
843+
.execution_options(**execution_opts)
844+
)
838845
row = await conn.first(query)
839846
return row
840847

@@ -851,7 +858,8 @@ async def _execute_and_fetch(conn, query):
851858

852859
def _cast_json(column, value):
853860
# FIXME: for MySQL, json string in WHERE clause needs to be cast to JSON type
854-
if (isinstance(column.type, sa.JSON) or
855-
isinstance(getattr(column.type, 'impl', None), sa.JSON)):
861+
if isinstance(column.type, sa.JSON) or isinstance(
862+
getattr(column.type, "impl", None), sa.JSON
863+
):
856864
return sa.cast(value, sa.JSON)
857865
return value

src/gino/dialects/base.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,9 @@ def __init__(self, context):
196196
def context(self):
197197
return self._context
198198

199-
async def execute(self, one=False, return_model=True, status=False,
200-
return_context=False):
199+
async def execute(
200+
self, one=False, return_model=True, status=False, return_context=False
201+
):
201202
context = self._context
202203

203204
param_groups = []

0 commit comments

Comments
 (0)