Beispiel #1
0
    def test_update_with_q(self):
        uq = UpdateQuery(Blog, title='A').where(Q(id=1))
        self.assertEqual(uq.sql(),
                         ('UPDATE blog SET title=? WHERE id = ?', ['A', 1]))

        uq = UpdateQuery(Blog, title='A').where(Q(id=1) | Q(id=3))
        self.assertEqual(
            uq.sql(),
            ('UPDATE blog SET title=? WHERE (id = ? OR id = ?)', ['A', 1, 3]))
Beispiel #2
0
    def test_update(self):
        iq = InsertQuery(Blog, title="a").execute()

        uq = UpdateQuery(Blog, title="A").where(id=1)
        self.assertEqual(uq.sql(), ("UPDATE blog SET title=? WHERE id = ?", ["A", 1]))
        self.assertEqual(uq.execute(), 1)

        iq2 = InsertQuery(Blog, title="b").execute()

        uq = UpdateQuery(Blog, title="B").where(id=2)
        self.assertEqual(uq.sql(), ("UPDATE blog SET title=? WHERE id = ?", ["B", 2]))
        self.assertEqual(uq.execute(), 1)

        sq = SelectQuery(Blog).order_by("id")
        self.assertEqual([x.title for x in sq], ["A", "B"])
Beispiel #3
0
 def test_update(self):
     iq = InsertQuery(Blog, title='a').execute()
     
     uq = UpdateQuery(Blog, title='A').where(id=1)
     self.assertEqual(uq.sql(), ('UPDATE blog SET title=? WHERE id = ?', ['A', 1]))
     self.assertEqual(uq.execute(), 1)
     
     iq2 = InsertQuery(Blog, title='b').execute()
     
     uq = UpdateQuery(Blog, title='B').where(id=2)
     self.assertEqual(uq.sql(), ('UPDATE blog SET title=? WHERE id = ?', ['B', 2]))
     self.assertEqual(uq.execute(), 1)
     
     sq = SelectQuery(Blog).order_by('id')
     self.assertEqual([x.title for x in sq], ['A', 'B'])
Beispiel #4
0
 def test_update(self):
     iq = InsertQuery(Blog, title='a').execute()
     
     uq = UpdateQuery(Blog, title='A').where(id=1)
     self.assertEqual(uq.sql(), ('UPDATE blog SET title=? WHERE id = ?', ['A', 1]))
     self.assertEqual(uq.execute(), 1)
     
     iq2 = InsertQuery(Blog, title='b').execute()
     
     uq = UpdateQuery(Blog, title='B').where(id=2)
     self.assertEqual(uq.sql(), ('UPDATE blog SET title=? WHERE id = ?', ['B', 2]))
     self.assertEqual(uq.execute(), 1)
     
     sq = SelectQuery(Blog).order_by('id')
     self.assertEqual([x.title for x in sq], ['A', 'B'])
Beispiel #5
0
    def test_update_with_q(self):
        uq = UpdateQuery(Blog, title="A").where(Q(id=1))
        self.assertEqual(uq.sql(), ("UPDATE blog SET title=? WHERE id = ?", ["A", 1]))

        uq = UpdateQuery(Blog, title="A").where(Q(id=1) | Q(id=3))
        self.assertEqual(uq.sql(), ("UPDATE blog SET title=? WHERE (id = ? OR id = ?)", ["A", 1, 3]))
Beispiel #6
0
 def test_update_with_q(self):
     uq = UpdateQuery(Blog, title='A').where(Q(id=1))
     self.assertEqual(uq.sql(), ('UPDATE blog SET title=? WHERE id = ?', ['A', 1]))
     
     uq = UpdateQuery(Blog, title='A').where(Q(id=1) | Q(id=3))
     self.assertEqual(uq.sql(), ('UPDATE blog SET title=? WHERE (id = ? OR id = ?)', ['A', 1, 3]))