def test_last_insert_id_in_query(self): ab1 = Alphabet.objects.create(a=3719, b=717612) ab2 = Alphabet.objects.create(a=1838, b=12636) # Delete but store value of b and re-assign it to first second Alphabet Alphabet.objects.filter(id=ab1.id, b=LastInsertId('b')).delete() Alphabet.objects.filter(id=ab2.id).update(b=LastInsertId()) ab = Alphabet.objects.get() assert ab.b == 717612
def test_last_insert_id_other_db_connection(self): Alphabet.objects.using('other').create(a=9191) Alphabet.objects.using('other').update(a=LastInsertId('a') + 9) lid = LastInsertId.get(using='other') assert lid == 9191
def test_last_insert_id(self): Alphabet.objects.create(a=7891) Alphabet.objects.update(a=LastInsertId('a') + 1) lid = LastInsertId.get() assert lid == 7891