mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-26 09:16:10 -06:00
Restore Empty lookup logic
This commit is contained in:
parent
f632a536d4
commit
ada6ab0b85
@ -6,12 +6,14 @@ class Empty(Lookup):
|
|||||||
Filter on whether a string is empty.
|
Filter on whether a string is empty.
|
||||||
"""
|
"""
|
||||||
lookup_name = 'empty'
|
lookup_name = 'empty'
|
||||||
|
prepare_rhs = False
|
||||||
|
|
||||||
def as_sql(self, qn, connection):
|
def as_sql(self, compiler, connection):
|
||||||
lhs, lhs_params = self.process_lhs(qn, connection)
|
sql, params = compiler.compile(self.lhs)
|
||||||
rhs, rhs_params = self.process_rhs(qn, connection)
|
if self.rhs:
|
||||||
params = lhs_params + rhs_params
|
return f"CAST(LENGTH({sql}) AS BOOLEAN) IS NOT TRUE", params
|
||||||
return 'CAST(LENGTH(%s) AS BOOLEAN) != %s' % (lhs, rhs), params
|
else:
|
||||||
|
return f"CAST(LENGTH({sql}) AS BOOLEAN) IS TRUE", params
|
||||||
|
|
||||||
|
|
||||||
CharField.register_lookup(Empty)
|
CharField.register_lookup(Empty)
|
||||||
|
Loading…
Reference in New Issue
Block a user