コード例 #1
0
ファイル: test_joins.py プロジェクト: kayak/pypika
    def test_join_table_on_update_query(self):
        a, b = Tables('a', 'b')
        q = Query.update(a) \
            .join(b).on(a.fkey_id == b.id) \
            .where(b.foo == 1) \
            .set('adwords_batch_job_id', 1)

        self.assertEqual('UPDATE "a" '
                         'JOIN "b" '
                         'ON "a"."fkey_id"="b"."id" '
                         'SET "adwords_batch_job_id"=1 '
                         'WHERE "b"."foo"=1', str(q))
コード例 #2
0
ファイル: test_updates.py プロジェクト: kayak/pypika
 def test_update_with_none(self):
     q = Query.update('abc').set('foo', None)
     self.assertEqual('UPDATE "abc" SET "foo"=null', str(q))
コード例 #3
0
ファイル: test_updates.py プロジェクト: kayak/pypika
    def test_update__table_schema(self):
        table = Table('abc', 'schema1')
        q = Query.update(table).set(table.foo, 1).where(table.foo == 0)

        self.assertEqual('UPDATE "schema1"."abc" SET "foo"=1 WHERE "foo"=0', str(q))
コード例 #4
0
ファイル: test_updates.py プロジェクト: kayak/pypika
    def test_single_quote_escape_in_set(self):
        q = Query.update(self.table_abc).set('foo', "bar'foo")

        self.assertEqual('UPDATE "abc" SET "foo"=\'bar\'\'foo\'', str(q))
コード例 #5
0
ファイル: test_updates.py プロジェクト: kayak/pypika
    def test_omit_where(self):
        q = Query.update(self.table_abc).set('foo', 'bar')

        self.assertEqual('UPDATE "abc" SET "foo"=\'bar\'', str(q))
コード例 #6
0
ファイル: test_updates.py プロジェクト: kayak/pypika
    def test_empty_query(self):
        q = Query.update('abc')

        self.assertEqual('', str(q))
コード例 #7
0
ファイル: test_query.py プロジェクト: wsf1990/pypika
    def test_replace_update_table(self):
        query = Query.update(self.table_a).set('foo', 'bar')
        query = query.replace_table(self.table_a, self.table_b)

        self.assertEqual('UPDATE "b" SET "foo"=\'bar\'', str(query))
コード例 #8
0
    def test_single_quote_escape_in_set(self):
        q = Query.update(self.table_abc).set('foo', "bar'foo")

        self.assertEqual('UPDATE "abc" SET "foo"=\'bar\'\'foo\'', str(q))
コード例 #9
0
    def test_update__table_schema(self):
        table = Table("abc", "schema1")
        q = Query.update(table).set(table.foo, 1).where(table.foo == 0)

        self.assertEqual('UPDATE "schema1"."abc" SET "foo"=1 WHERE "foo"=0',
                         str(q))
コード例 #10
0
    def test_single_quote_escape_in_set(self):
        q = Query.update(self.table_abc).set("foo", "bar'foo")

        self.assertEqual("UPDATE \"abc\" SET \"foo\"='bar''foo'", str(q))
コード例 #11
0
    def test_omit_where(self):
        q = Query.update(self.table_abc).set("foo", "bar")

        self.assertEqual('UPDATE "abc" SET "foo"=\'bar\'', str(q))
コード例 #12
0
    def test_empty_query(self):
        q = Query.update("abc")

        self.assertEqual("", str(q))
コード例 #13
0
ファイル: client_model.py プロジェクト: totoer/tula_web_cup
 async def delete(cls, client_id):
     query = Query.update(client).set('is_remove',
                                      True).where(client.id == client_id)
     await cls.db.execute(query.get_sql())
コード例 #14
0
ファイル: test_updates.py プロジェクト: moorecode/pypika
    def test_update_from(self):
        from_table = Table('from_table')

        q = Query.update(self.table_abc).set(self.table_abc.lname, from_table.long_name).from_(from_table)
        self.assertEqual('UPDATE "abc" SET "lname"="from_table"."long_name" FROM "from_table"', str(q))
コード例 #15
0
ファイル: test_updates.py プロジェクト: moorecode/pypika
 def test_update_with_limit(self):
     q = Query.update(self.table_abc).set(self.table_abc.lname, "test").limit(1)
     self.assertEqual('UPDATE "abc" SET "lname"=\'test\' LIMIT 1', str(q))
コード例 #16
0
ファイル: test_updates.py プロジェクト: kayak/pypika
 def test_update_with_join(self):
     q = Query.update(self.table_abc).join(self.table_def).on(self.table_def.abc_id == self.table_abc.id).set(self.table_abc.lname, self.table_def.lname)
     self.assertEqual('UPDATE "abc" JOIN "def" ON "def"."abc_id"="abc"."id" SET "abc"."lname"="def"."lname"', str(q))
コード例 #17
0
 def test_update_with_none(self):
     q = Query.update("abc").set("foo", None)
     self.assertEqual('UPDATE "abc" SET "foo"=null', str(q))
コード例 #18
0
    def test_empty_query(self):
        q = Query.update('abc')

        self.assertEqual('', str(q))