Last active
May 28, 2020 06:59
-
-
Save simkimsia/60149d5ab4bad1817fc33315dc11b300 to your computer and use it in GitHub Desktop.
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
@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 |
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
> /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']) |
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
@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 |
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
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 [email protected] |
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
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