Example #1
0
    def test_db_update_a_lot_of_cols(self):
        db.create_table('t', default_cols(id='integer', number='integer'))
        db.create_many('t', ('id', 'number'), ((1, i) for i in range(10)))
        for row in db.all('t'):
            self.assertNotEqual(row['number'], -1)

        qb.table('t').where('id', '=', 1).update({'number': -1})
        for row in db.all('t'):
            self.assertEqual(row['number'], -1)
Example #2
0
    def test_update_all(self):
        db.create_table('t', default_cols(id='integer'))
        db.create_many('t', ('id', ), ((1, ) for _ in range(10)))

        qb.table('t').update({'id': 0})
        for row in db.all('t'):
            self.assertEqual(row['id'], 0)
Example #3
0
    def test_db_update_equal_works(self):
        db.create_table('t', default_cols(id='integer'))
        db.create('t', id=1)

        qb.table('t').where('id', '=', 1).update({'id': 2})

        self.assertEqual(next(db.all('t'))['id'], 2)
Example #4
0
 def setUp(self):
     db.create_table('tests', default_cols(a='text'))
     db.create_many('tests', ('a', ), ('a', 'b', 'c'))
     self.mc = ModelContainer(db.all('tests'), Test)
Example #5
0
    def test_db_update_doesnt_update_not_found_columns(self):
        db.create_table('t', default_cols(id='integer'))
        db.create('t', id=0)
        qb.table('t').where('id', '=', '1').update({'id': 2})

        self.assertEqual(next(db.all('t'))['id'], 0)