def test_multiple_where_clauses(self):
     """where clause with multiple conditions generates correctly"""
     with connection.schema_editor() as editor:
         sql = PgPartialIndex(
             fields=['has_events'],
             name='test_partial',
             where={
                 'has_events__gte': 42,
                 'is_hidden': True,
             },
         ).create_sql(Thread, editor)
         self.assertTrue(sql.endswith('WHERE "has_events" >= 42 AND "is_hidden" = true'))
 def test_multiple_where_clauses(self):
     """where clause with multiple conditions generates correctly"""
     with connection.schema_editor() as editor:
         sql = PgPartialIndex(
             fields=['has_events'],
             name='test_partial',
             where={
                 'has_events__gte': 42,
                 'is_hidden': True,
             },
         ).create_sql(Thread, editor)
         self.assertTrue(
             sql.endswith(
                 'WHERE "has_events" >= 42 AND "is_hidden" = true'))
    def test_where_clauses(self):
        """where clauses generate correctly"""
        with connection.schema_editor() as editor:
            sql = PgPartialIndex(
                fields=['has_events'],
                name='test_partial',
                where={'has_events': True},
            ).create_sql(Thread, editor)

            self.assertTrue(sql.endswith('WHERE "has_events" = true'))

            sql = PgPartialIndex(
                fields=['has_events'],
                name='test_partial',
                where={'has_events': False},
            ).create_sql(Thread, editor)
            self.assertTrue(sql.endswith('WHERE "has_events" = false'))

            sql = PgPartialIndex(
                fields=['has_events'],
                name='test_partial',
                where={'has_events': 42},
            ).create_sql(Thread, editor)
            self.assertTrue(sql.endswith('WHERE "has_events" = 42'))

            sql = PgPartialIndex(
                fields=['has_events'],
                name='test_partial',
                where={'has_events__lt': 42},
            ).create_sql(Thread, editor)
            self.assertTrue(sql.endswith('WHERE "has_events" < 42'))

            sql = PgPartialIndex(
                fields=['has_events'],
                name='test_partial',
                where={'has_events__gt': 42},
            ).create_sql(Thread, editor)
            self.assertTrue(sql.endswith('WHERE "has_events" > 42'))

            sql = PgPartialIndex(
                fields=['has_events'],
                name='test_partial',
                where={'has_events__lte': 42},
            ).create_sql(Thread, editor)
            self.assertTrue(sql.endswith('WHERE "has_events" <= 42'))

            sql = PgPartialIndex(
                fields=['has_events'],
                name='test_partial',
                where={'has_events__gte': 42},
            ).create_sql(Thread, editor)
            self.assertTrue(sql.endswith('WHERE "has_events" >= 42'))
    def test_where_clauses(self):
        """where clauses generate correctly"""
        with connection.schema_editor() as editor:
            sql = PgPartialIndex(
                fields=['has_events'],
                name='test_partial',
                where={
                    'has_events': True
                },
            ).create_sql(Thread, editor)

            self.assertTrue(sql.endswith('WHERE "has_events" = true'))

            sql = PgPartialIndex(
                fields=['has_events'],
                name='test_partial',
                where={
                    'has_events': False
                },
            ).create_sql(Thread, editor)
            self.assertTrue(sql.endswith('WHERE "has_events" = false'))

            sql = PgPartialIndex(
                fields=['has_events'],
                name='test_partial',
                where={
                    'has_events': 42
                },
            ).create_sql(Thread, editor)
            self.assertTrue(sql.endswith('WHERE "has_events" = 42'))

            sql = PgPartialIndex(
                fields=['has_events'],
                name='test_partial',
                where={
                    'has_events__lt': 42
                },
            ).create_sql(Thread, editor)
            self.assertTrue(sql.endswith('WHERE "has_events" < 42'))

            sql = PgPartialIndex(
                fields=['has_events'],
                name='test_partial',
                where={
                    'has_events__gt': 42
                },
            ).create_sql(Thread, editor)
            self.assertTrue(sql.endswith('WHERE "has_events" > 42'))

            sql = PgPartialIndex(
                fields=['has_events'],
                name='test_partial',
                where={
                    'has_events__lte': 42
                },
            ).create_sql(Thread, editor)
            self.assertTrue(sql.endswith('WHERE "has_events" <= 42'))

            sql = PgPartialIndex(
                fields=['has_events'],
                name='test_partial',
                where={
                    'has_events__gte': 42
                },
            ).create_sql(Thread, editor)
            self.assertTrue(sql.endswith('WHERE "has_events" >= 42'))