@KeyTransform.register_lookup | |
class KeyTransformIsInteger(KeyTransformTextLookupMixin, Lookup): | |
lookup_name = "is_int" | |
def as_sql(self, compiler, connection): | |
import ipdb | |
ipdb.set_trace() | |
lhs, lhs_params = self.process_lhs(compiler, connection) | |
rhs, rhs_params = self.process_rhs(compiler, connection) | |
params = lhs_params + lhs_params + rhs_params | |
sql = "(jsonb_typeof(%s) = 'number' AND (%s)::numeric %% 1 = 0) is %s" | |
result = sql % (lhs, lhs, rhs), params | |
return result |
> /app/rea/models/structural/linkages.py(31)as_sql() | |
30 result = sql % (lhs, lhs, rhs), params | |
---> 31 return result | |
32 | |
ipdb> result | |
('(jsonb_typeof(("linkage" #>> %s)) = \'number\' AND (("linkage" #>> %s))::numeric % 1 = 0) is %s', [['root', 'in_subproject'], ['root', 'in_subproject'], 'True']) |
@KeyTransform.register_lookup | |
class KeyTransformIsInteger(KeyTransformTextLookupMixin, Lookup): | |
lookup_name = "is_int" | |
def as_sql(self, compiler, connection): | |
import ipdb | |
ipdb.set_trace() | |
lhs_sql, params = self.process_lhs(compiler, connection) | |
rhs_sql, rhs_params = self.process_rhs(compiler, connection) | |
params.extend(params) | |
params.extend(rhs_params) | |
sql = "(jsonb_typeof(%s) = 'number' AND (%s)::numeric %% 1 = 0) IS %s" | |
result = sql % (lhs_sql, lhs_sql, rhs_sql), params | |
return result |
File "/usr/local/lib/python3.7/site-packages/django/db/backends/base/schema.py", line 343, in add_constraint | |
sql = constraint.create_sql(model, self) | |
File "/usr/local/lib/python3.7/site-packages/django/db/models/constraints.py", line 47, in create_sql | |
check = self._get_check_sql(model, schema_editor) | |
File "/usr/local/lib/python3.7/site-packages/django/db/models/constraints.py", line 40, in _get_check_sql | |
return sql % tuple(schema_editor.quote_value(p) for p in params) | |
ValueError: unsupported format character ' ' (0x20) at index 82 | |
If you suspect this is an IPython 7.14.0 bug, please report it at: | |
https://github.com/ipython/ipython/issues | |
or send an email to the mailing list at ipython-dev@python.org |
ipdb> lhs_sql | |
'("linkage" #>> %s)' | |
ipdb> lhs_params | |
[['root', 'in_subproject']] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment