Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 9033992

Browse filesBrowse files
committed
simplify literal processor
1 parent 9c0c560 commit 9033992
Copy full SHA for 9033992

File tree

2 files changed

+7
-8
lines changed
Filter options

2 files changed

+7
-8
lines changed

‎sqlalchemy_bigquery/_json.py

Copy file name to clipboardExpand all lines: sqlalchemy_bigquery/_json.py
+3-5Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ def bind_expression(self, bindvalue):
3636
return sqlalchemy.func.PARSE_JSON(bindvalue, type_=self)
3737

3838
def literal_processor(self, dialect):
39-
json_serializer = dialect._json_serializer or json.dumps
39+
super_proc = self.bind_processor(dialect)
4040

4141
def process(value):
42-
value = json_serializer(value)
42+
value = super_proc(value)
4343
return repr(value)
4444

4545
return process
@@ -67,9 +67,7 @@ def as_float(self, lax=False):
6767
return func_(self.expr, type_=sqltypes.Float)
6868

6969
def as_numeric(self, precision, scale, asdecimal=True):
70-
# No converter available - technically we could cast, but even
71-
# then we can't satisfy this interface because it is not possible
72-
# to cast to parameterized types.
70+
# No converter available in BigQuery
7371
raise NotImplementedError()
7472

7573
comparator_factory = Comparator

‎tests/unit/test__json.py

Copy file name to clipboardExpand all lines: tests/unit/test__json.py
+4-3Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,12 +139,13 @@ def test_json_casts(faux_conn, json_column, json_data, lax):
139139
f"SELECT {prefix}BOOL(PARSE_JSON('true')) = true AS `anon_1`"
140140
)
141141

142-
# TODO: Casting as described in https://docs.sqlalchemy.org/en/20/core/type_basics.html#sqlalchemy.types.JSON
142+
def test_nulls(faux_conn, json_column, json_data):
143+
pass
143144

144145
# TODO: Test SQL NULL vs JSON null as described above
145146

146-
# TODO: Test documented differences between JSON and JSON-formatted STRING
147-
148147
# TODO: Support lax + lax recursive
149148

149+
# TODO: Test documented differences between JSON and JSON-formatted STRING
150+
150151
# TODO: Provide some GenericFunction, or at least docs for how to use type_

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.