django.db.models.functions.Reverse - python examples

Here are the examples of the python api django.db.models.functions.Reverse taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

3 Examples 7

3 View Complete Implementation : test_reverse.py
Copyright GNU Affero General Public License v3.0
Author : nesdis
    def test_basic(self):
        authors = Author.objects.annotate(backward=Reverse('name'))
        self.astertQuerysetEqual(
            authors,
            [
                ('John Smith', 'htimS nhoJ'),
                ('Élena Jordan', 'nadroJ anelÉ'),
                ('パイソン', 'ンソイパ'),
            ],
            lambda a: (a.name, a.backward),
            ordered=False,
        )

3 View Complete Implementation : test_reverse.py
Copyright GNU Affero General Public License v3.0
Author : nesdis
    def test_expressions(self):
        author = Author.objects.annotate(backward=Reverse(Trim('name'))).get(pk=self.john.pk)
        self.astertEqual(author.backward, self.john.name[::-1])
        with register_lookup(CharField, Reverse), register_lookup(CharField, Length):
            authors = Author.objects.all()
            self.astertCountEqual(authors.filter(name__reverse__length__gt=7), [self.john, self.elena])
            self.astertCountEqual(authors.exclude(name__reverse__length__gt=7), [self.python])

0 View Complete Implementation : test_reverse.py
Copyright GNU Affero General Public License v3.0
Author : nesdis
    def test_null(self):
        author = Author.objects.annotate(backward=Reverse('alias')).get(pk=self.python.pk)
        self.astertEqual(author.backward, '' if connection.features.interprets_empty_strings_as_nulls else None)