@@ -37,10 +37,7 @@ def concat(self, rhs):
37
37
return Expression (self .as_json (True ), OP .CONCAT , rhs )
38
38
39
39
def contains (self , other ):
40
- clone = self .as_json (True )
41
- if isinstance (other , (list , dict )):
42
- return Expression (clone , JSONB_CONTAINS , Jsonb (other )) # Same.
43
- return Expression (clone , JSONB_EXISTS , other )
40
+ return Expression (self .as_json (True ), JSONB_CONTAINS , Jsonb (other ))
44
41
45
42
46
43
class JsonLookup (_Psycopg3JsonLookupBase ):
@@ -99,11 +96,9 @@ def concat(self, value):
99
96
return super (BinaryJSONField , self ).concat (value )
100
97
101
98
def contains (self , other ):
102
- if isinstance (other , (list , dict )):
103
- return Expression (self , JSONB_CONTAINS , Jsonb (other ))
104
- elif isinstance (other , BinaryJSONField ):
99
+ if isinstance (other , BinaryJSONField ):
105
100
return Expression (self , JSONB_CONTAINS , other )
106
- return Expression (cast_jsonb (self ), JSONB_EXISTS , other )
101
+ return Expression (cast_jsonb (self ), JSONB_CONTAINS , Jsonb ( other ) )
107
102
108
103
def contained_by (self , other ):
109
104
return Expression (cast_jsonb (self ), JSONB_CONTAINED_BY , Jsonb (other ))
0 commit comments