예제 #1
0
 def test_elt_simple(self):
     Alphabet.objects.create(a=2)
     ab = Alphabet.objects.annotate(elt=ELT("a", ["apple", "orange"])).get()
     assert ab.elt == "orange"
     ab = Alphabet.objects.annotate(elt=ELT("a", ["apple"])).get()
     assert ab.elt is None
예제 #2
0
 def test_elt_simple(self):
     Alphabet.objects.create(a=2)
     ab = Alphabet.objects.annotate(elt=ELT('a', ['apple', 'orange'])).get()
     assert ab.elt == 'orange'
     ab = Alphabet.objects.annotate(elt=ELT('a', ['apple'])).get()
     assert ab.elt is None
예제 #3
0
 def test_elt_expression(self):
     Alphabet.objects.create(a=1)
     ab = Alphabet.objects.annotate(
         elt=ELT("a", [Value("apple"), Value("orange")])).get()
     assert ab.elt == "apple"