@@ -405,9 +405,9 @@ def test_partial_index(self):
405
405
),
406
406
),
407
407
)
408
- self .assertIn (
409
- "WHERE %s" % editor . quote_name ( "pub_date" ) ,
410
- str (index .create_sql (Article , schema_editor = editor )),
408
+ self .assertEqual (
409
+ "{'pub_date': {'$gt': datetime.datetime(2015, 1, 1, 6, 0)}}" ,
410
+ str (index ._get_condition_mql (Article , schema_editor = editor )),
411
411
)
412
412
editor .add_index (index = index , model = Article )
413
413
with connection .cursor () as cursor :
@@ -424,12 +424,13 @@ def test_integer_restriction_partial(self):
424
424
with connection .schema_editor () as editor :
425
425
index = Index (
426
426
name = "recent_article_idx" ,
427
- fields = ["id" ],
427
+ # This is changed
428
+ fields = ["headline" ],
428
429
condition = Q (pk__gt = 1 ),
429
430
)
430
- self .assertIn (
431
- "WHERE %s" % editor . quote_name ( "id" ) ,
432
- str (index .create_sql (Article , schema_editor = editor )),
431
+ self .assertEqual (
432
+ "{'_id': {'$gt': 1}}" ,
433
+ str (index ._get_condition_mql (Article , schema_editor = editor )),
433
434
)
434
435
editor .add_index (index = index , model = Article )
435
436
with connection .cursor () as cursor :
@@ -449,9 +450,9 @@ def test_boolean_restriction_partial(self):
449
450
fields = ["published" ],
450
451
condition = Q (published = True ),
451
452
)
452
- self .assertIn (
453
- "WHERE %s" % editor . quote_name ( "published" ) ,
454
- str (index .create_sql (Article , schema_editor = editor )),
453
+ self .assertEqual (
454
+ "{'published': {'$eq': True}}" ,
455
+ str (index ._get_condition_mql (Article , schema_editor = editor )),
455
456
)
456
457
editor .add_index (index = index , model = Article )
457
458
with connection .cursor () as cursor :
@@ -482,12 +483,13 @@ def test_multiple_conditions(self):
482
483
& Q (headline__contains = "China" )
483
484
),
484
485
)
485
- sql = str (index .create_sql (Article , schema_editor = editor ))
486
- where = sql .find ("WHERE" )
487
- self .assertIn ("WHERE (%s" % editor .quote_name ("pub_date" ), sql )
486
+ sql = str (index ._get_condition_mql (Article , schema_editor = editor ))
487
+ self .assertEqual (sql , "... TO FILL IN ..." )
488
+ # where = sql.find("WHERE")
489
+ # self.assertIn("WHERE (%s" % editor.quote_name("pub_date"), sql)
488
490
# Because each backend has different syntax for the operators,
489
491
# check ONLY the occurrence of headline in the SQL.
490
- self .assertGreater (sql .rfind ("headline" ), where )
492
+ # self.assertGreater(sql.rfind("headline"), where)
491
493
editor .add_index (index = index , model = Article )
492
494
with connection .cursor () as cursor :
493
495
self .assertIn (
@@ -506,9 +508,10 @@ def test_is_null_condition(self):
506
508
fields = ["pub_date" ],
507
509
condition = Q (pub_date__isnull = False ),
508
510
)
509
- self . assertIn (
510
- "WHERE %s IS NOT NULL" % editor . quote_name ( "pub_date" ),
511
+
512
+ self . assertEqual (
511
513
str (index .create_sql (Article , schema_editor = editor )),
514
+ "... TO FILL IN ..." ,
512
515
)
513
516
editor .add_index (index = index , model = Article )
514
517
with connection .cursor () as cursor :
0 commit comments