File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -116,3 +116,35 @@ def test_composite_op_index(self):
116116 ),
117117 )
118118 editor .remove_index (index = index , model = Article )
119+
120+ def test_simple_operations (self ):
121+ mongo_operators_idx = (
122+ ("gt" , "$gt" ),
123+ ("gte" , "$gte" ),
124+ ("lt" , "$lt" ),
125+ ("lte" , "$lte" ),
126+ )
127+
128+ for op , mongo_operator in mongo_operators_idx :
129+ with self .subTest (operator = op ), connection .schema_editor () as editor :
130+ index = Index (
131+ name = "composite_proposition" ,
132+ fields = ["headline" ],
133+ condition = Q (** {f"number__{ op } " : 3 }),
134+ )
135+ index ._get_condition_mql (Article , schema_editor = editor )
136+ target = {"number" : {mongo_operator : 3 }}
137+ self .assertEqual (
138+ target ,
139+ index ._get_condition_mql (Article , schema_editor = editor ),
140+ )
141+ editor .add_index (index = index , model = Article )
142+ with connection .cursor () as cursor :
143+ self .assertIn (
144+ index .name ,
145+ connection .introspection .get_constraints (
146+ cursor = cursor ,
147+ table_name = Article ._meta .db_table ,
148+ ),
149+ )
150+ editor .remove_index (index = index , model = Article )
You can’t perform that action at this time.
0 commit comments