@@ -34,16 +34,19 @@ def add_filter(self, (filter_string, value), *args, **kwargs):
34
34
35
35
class NetWhere (sql .where .WhereNode ):
36
36
def make_atom (self , child , qn , conn ):
37
- if isinstance (child [0 ], sql .where .Constraint ):
38
- c = child [0 ]
39
- table_alias = c .alias
40
- name = c .col
41
- field = c .field
42
- lookup_type , value_annot , params = child [1 :]
37
+ lvalue , lookup_type , value_annot , params_or_value = child
38
+
39
+ if hasattr (lvalue , 'process' ):
40
+ try :
41
+ lvalue , params = lvalue .process (lookup_type , params_or_value , connection )
42
+ except EmptyShortCircuit :
43
+ raise EmptyResultSet
43
44
else :
44
- table_alias , name , db_type , lookup_type , value_annot , params = child
45
+ return super (NetWhere , self ).make_atom (child , qn , conn )
46
+
47
+ table_alias , name , db_type = lvalue
45
48
46
- if field . db_type () not in ['inet' , 'cidr' ]:
49
+ if db_type not in ['inet' , 'cidr' ]:
47
50
return super (NetWhere , self ).make_atom (child , qn , conn )
48
51
49
52
if table_alias :
@@ -52,7 +55,7 @@ def make_atom(self, child, qn, conn):
52
55
field_sql = qn (name )
53
56
54
57
if NET_OPERATORS .get (lookup_type , '' ) in NET_TEXT_OPERATORS :
55
- if field . db_type () == 'inet' :
58
+ if db_type == 'inet' :
56
59
field_sql = 'HOST(%s)' % field_sql
57
60
else :
58
61
field_sql = 'TEXT(%s)' % field_sql
0 commit comments