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
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
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"