[tryton-debian-vcs] python-sql branch upstream updated. upstream/0.5-1-g14b2421

Mathias Behrle tryton-debian-vcs at alioth.debian.org
Wed Feb 18 11:54:23 UTC 2015


The following commit has been merged in the upstream branch:
https://alioth.debian.org/plugins/scmgit/cgi-bin/gitweb.cgi/?p=tryton/python-sql.git;a=commitdiff;h=upstream/0.5-1-g14b2421

commit 14b2421e6f66e3125446aec3fe37ac6860aa04bd
Author: Mathias Behrle <mathiasb at m9s.biz>
Date:   Wed Feb 18 12:50:23 2015 +0100

    Adding upstream version 0.6.
    
    Signed-off-by: Mathias Behrle <mathiasb at m9s.biz>

diff --git a/CHANGELOG b/CHANGELOG
index e11ec39..a52b0bd 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,7 @@
+Version 0.6 - 2015-02-05
+* Fix Delete query under multithread
+* Add missing quote for with query name
+
 Version 0.5 - 2015-01-29
 * Add schema
 * Add Common Table Expression
diff --git a/PKG-INFO b/PKG-INFO
index 288675b..432eb1e 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: python-sql
-Version: 0.5
+Version: 0.6
 Summary: Library to write SQL queries
 Home-page: http://code.google.com/p/python-sql/
 Author: B2CK
@@ -94,9 +94,9 @@ Description: python-sql
         
             >>> user_group = Table('user_group')
             >>> subselect = user_group.select(user_group.user,
-            ...     where=(user_group.active == True))
+            ...     where=user_group.active == True)
             >>> user = Table('user')
-            >>> tuple(user.select(user.id, where=(user.id.in_(subselect))))
+            >>> tuple(user.select(user.id, where=user.id.in_(subselect)))
             ('SELECT "a"."id" FROM "user" AS "a" WHERE ("a"."id" IN (SELECT "b"."user" FROM "user_group" AS "b" WHERE ("b"."active" = %s)))', (True,))
             >>> tuple(subselect.select(subselect.user))
             ('SELECT "a"."user" FROM (SELECT "b"."user" FROM "user_group" AS "b" WHERE ("b"."active" = %s)) AS "a"', (True,))
@@ -137,15 +137,15 @@ Description: python-sql
         
         Update query with where condition::
         
-            >>> tuple(user.update(columns=[user.active], values=[True], where=(
-            ...         user.active == False)))
+            >>> tuple(user.update(columns=[user.active], values=[True],
+            ...          where=user.active == False))
             ('UPDATE "user" SET "active" = %s WHERE ("user"."active" = %s)', (True, False))
         
         Update query with from list::
         
             >>> group = Table('user_group')
             >>> tuple(user.update(columns=[user.active], values=[group.active],
-            ...         from_=[group], where=(user.id == group.user)))
+            ...         from_=[group], where=user.id == group.user))
             ('UPDATE "user" AS "b" SET "active" = "a"."active" FROM "user_group" AS "a" WHERE ("b"."id" = "a"."user")', ())
         
         Delete query::
@@ -155,13 +155,13 @@ Description: python-sql
         
         Delete query with where condition::
         
-            >>> tuple(user.delete(where=(user.name == 'foo')))
+            >>> tuple(user.delete(where=user.name == 'foo'))
             ('DELETE FROM "user" WHERE ("name" = %s)', ('foo',))
         
         Delete query with sub-query::
         
-            >>> tuple(user.delete(where=(
-            ...             user.id.in_(user_group.select(user_group.user)))))
+            >>> tuple(user.delete(
+            ...             where=user.id.in_(user_group.select(user_group.user))))
             ('DELETE FROM "user" WHERE ("id" IN (SELECT "a"."user" FROM "user_group" AS "a"))', ())
         
         Flavors::
@@ -179,7 +179,7 @@ Description: python-sql
             ('SELECT * FROM "user" AS "a" LIMIT -1 OFFSET 10', ())
             >>> Flavor.set(Flavor(paramstyle='qmark'))
             >>> select = user.select()
-            >>> select.where = (user.name == 'foo')
+            >>> select.where = user.name == 'foo'
             >>> tuple(select)
             ('SELECT * FROM "user" AS "a" WHERE ("a"."name" = ?)', ('foo',))
         
diff --git a/README b/README
index f7ee30f..ec5b752 100644
--- a/README
+++ b/README
@@ -86,9 +86,9 @@ Select with sub-select::
 
     >>> user_group = Table('user_group')
     >>> subselect = user_group.select(user_group.user,
-    ...     where=(user_group.active == True))
+    ...     where=user_group.active == True)
     >>> user = Table('user')
-    >>> tuple(user.select(user.id, where=(user.id.in_(subselect))))
+    >>> tuple(user.select(user.id, where=user.id.in_(subselect)))
     ('SELECT "a"."id" FROM "user" AS "a" WHERE ("a"."id" IN (SELECT "b"."user" FROM "user_group" AS "b" WHERE ("b"."active" = %s)))', (True,))
     >>> tuple(subselect.select(subselect.user))
     ('SELECT "a"."user" FROM (SELECT "b"."user" FROM "user_group" AS "b" WHERE ("b"."active" = %s)) AS "a"', (True,))
@@ -129,15 +129,15 @@ Update query with values::
 
 Update query with where condition::
 
-    >>> tuple(user.update(columns=[user.active], values=[True], where=(
-    ...         user.active == False)))
+    >>> tuple(user.update(columns=[user.active], values=[True],
+    ...          where=user.active == False))
     ('UPDATE "user" SET "active" = %s WHERE ("user"."active" = %s)', (True, False))
 
 Update query with from list::
 
     >>> group = Table('user_group')
     >>> tuple(user.update(columns=[user.active], values=[group.active],
-    ...         from_=[group], where=(user.id == group.user)))
+    ...         from_=[group], where=user.id == group.user))
     ('UPDATE "user" AS "b" SET "active" = "a"."active" FROM "user_group" AS "a" WHERE ("b"."id" = "a"."user")', ())
 
 Delete query::
@@ -147,13 +147,13 @@ Delete query::
 
 Delete query with where condition::
 
-    >>> tuple(user.delete(where=(user.name == 'foo')))
+    >>> tuple(user.delete(where=user.name == 'foo'))
     ('DELETE FROM "user" WHERE ("name" = %s)', ('foo',))
 
 Delete query with sub-query::
 
-    >>> tuple(user.delete(where=(
-    ...             user.id.in_(user_group.select(user_group.user)))))
+    >>> tuple(user.delete(
+    ...             where=user.id.in_(user_group.select(user_group.user))))
     ('DELETE FROM "user" WHERE ("id" IN (SELECT "a"."user" FROM "user_group" AS "a"))', ())
 
 Flavors::
@@ -171,6 +171,6 @@ Flavors::
     ('SELECT * FROM "user" AS "a" LIMIT -1 OFFSET 10', ())
     >>> Flavor.set(Flavor(paramstyle='qmark'))
     >>> select = user.select()
-    >>> select.where = (user.name == 'foo')
+    >>> select.where = user.name == 'foo'
     >>> tuple(select)
     ('SELECT * FROM "user" AS "a" WHERE ("a"."name" = ?)', ('foo',))
diff --git a/python_sql.egg-info/PKG-INFO b/python_sql.egg-info/PKG-INFO
index 288675b..432eb1e 100644
--- a/python_sql.egg-info/PKG-INFO
+++ b/python_sql.egg-info/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: python-sql
-Version: 0.5
+Version: 0.6
 Summary: Library to write SQL queries
 Home-page: http://code.google.com/p/python-sql/
 Author: B2CK
@@ -94,9 +94,9 @@ Description: python-sql
         
             >>> user_group = Table('user_group')
             >>> subselect = user_group.select(user_group.user,
-            ...     where=(user_group.active == True))
+            ...     where=user_group.active == True)
             >>> user = Table('user')
-            >>> tuple(user.select(user.id, where=(user.id.in_(subselect))))
+            >>> tuple(user.select(user.id, where=user.id.in_(subselect)))
             ('SELECT "a"."id" FROM "user" AS "a" WHERE ("a"."id" IN (SELECT "b"."user" FROM "user_group" AS "b" WHERE ("b"."active" = %s)))', (True,))
             >>> tuple(subselect.select(subselect.user))
             ('SELECT "a"."user" FROM (SELECT "b"."user" FROM "user_group" AS "b" WHERE ("b"."active" = %s)) AS "a"', (True,))
@@ -137,15 +137,15 @@ Description: python-sql
         
         Update query with where condition::
         
-            >>> tuple(user.update(columns=[user.active], values=[True], where=(
-            ...         user.active == False)))
+            >>> tuple(user.update(columns=[user.active], values=[True],
+            ...          where=user.active == False))
             ('UPDATE "user" SET "active" = %s WHERE ("user"."active" = %s)', (True, False))
         
         Update query with from list::
         
             >>> group = Table('user_group')
             >>> tuple(user.update(columns=[user.active], values=[group.active],
-            ...         from_=[group], where=(user.id == group.user)))
+            ...         from_=[group], where=user.id == group.user))
             ('UPDATE "user" AS "b" SET "active" = "a"."active" FROM "user_group" AS "a" WHERE ("b"."id" = "a"."user")', ())
         
         Delete query::
@@ -155,13 +155,13 @@ Description: python-sql
         
         Delete query with where condition::
         
-            >>> tuple(user.delete(where=(user.name == 'foo')))
+            >>> tuple(user.delete(where=user.name == 'foo'))
             ('DELETE FROM "user" WHERE ("name" = %s)', ('foo',))
         
         Delete query with sub-query::
         
-            >>> tuple(user.delete(where=(
-            ...             user.id.in_(user_group.select(user_group.user)))))
+            >>> tuple(user.delete(
+            ...             where=user.id.in_(user_group.select(user_group.user))))
             ('DELETE FROM "user" WHERE ("id" IN (SELECT "a"."user" FROM "user_group" AS "a"))', ())
         
         Flavors::
@@ -179,7 +179,7 @@ Description: python-sql
             ('SELECT * FROM "user" AS "a" LIMIT -1 OFFSET 10', ())
             >>> Flavor.set(Flavor(paramstyle='qmark'))
             >>> select = user.select()
-            >>> select.where = (user.name == 'foo')
+            >>> select.where = user.name == 'foo'
             >>> tuple(select)
             ('SELECT * FROM "user" AS "a" WHERE ("a"."name" = ?)', ('foo',))
         
diff --git a/sql/__init__.py b/sql/__init__.py
index 52fb5f7..0a39deb 100644
--- a/sql/__init__.py
+++ b/sql/__init__.py
@@ -29,7 +29,7 @@
 
 from __future__ import division
 
-__version__ = '0.5'
+__version__ = '0.6'
 __all__ = ['Flavor', 'Table', 'Values', 'Literal', 'Column', 'Join',
     'Asc', 'Desc']
 
@@ -120,7 +120,7 @@ class AliasManager(object):
 
     def __init__(self, exclude=None):
         if exclude:
-            if self.local.exclude is None:
+            if getattr(self.local, 'exclude', None) is None:
                 self.local.exclude = []
             self.local.exclude.extend(exclude)
 
@@ -254,13 +254,13 @@ class With(FromItem):
     def statement(self):
         columns = ('(%s)' % ', '.join('"%s"' % c for c in self.columns)
             if self.columns else '')
-        return '%s%s AS (%s)' % (self.alias, columns, self.query)
+        return '"%s"%s AS (%s)' % (self.alias, columns, self.query)
 
     def statement_params(self):
         return self.query.params
 
     def __str__(self):
-        return self.alias
+        return '"%s"' % self.alias
 
     @property
     def params(self):
diff --git a/sql/aggregate.py b/sql/aggregate.py
index 0835031..ea75d20 100644
--- a/sql/aggregate.py
+++ b/sql/aggregate.py
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 # -*- coding: utf-8 -*-
 #
 # Copyright (c) 2011-2013, Cédric Krier
diff --git a/sql/tests/test_alias.py b/sql/tests/test_alias.py
index fcfed30..5b58017 100644
--- a/sql/tests/test_alias.py
+++ b/sql/tests/test_alias.py
@@ -46,7 +46,7 @@ class TestAliasManager(unittest.TestCase):
 
     def func1(self):
         try:
-            with AliasManager():
+            with AliasManager(exclude=[self.t2]):
                 a1 = AliasManager.get(self.t1)
                 a2 = AliasManager.get(self.t2)
                 self.synchro.wait()
@@ -61,7 +61,7 @@ class TestAliasManager(unittest.TestCase):
 
     def func2(self):
         try:
-            with AliasManager():
+            with AliasManager(exclude=[self.t2]):
                 a2 = AliasManager.get(self.t2)
                 a1 = AliasManager.get(self.t1)
                 self.synchro.set()
diff --git a/sql/tests/test_delete.py b/sql/tests/test_delete.py
index e629cf0..b82f1eb 100644
--- a/sql/tests/test_delete.py
+++ b/sql/tests/test_delete.py
@@ -65,6 +65,6 @@ class TestDelete(unittest.TestCase):
         query = self.table.delete(with_=[w],
             where=self.table.c2.in_(w.select(w.c3)))
         self.assertEqual(str(query),
-            'WITH a AS (SELECT "b"."c1" FROM "t1" AS "b") '
-            'DELETE FROM "t" WHERE ("c2" IN (SELECT "a"."c3" FROM a AS "a"))')
+            'WITH "a" AS (SELECT "b"."c1" FROM "t1" AS "b") '
+            'DELETE FROM "t" WHERE ("c2" IN (SELECT "a"."c3" FROM "a" AS "a"))')
         self.assertEqual(query.params, ())
diff --git a/sql/tests/test_insert.py b/sql/tests/test_insert.py
index a869de3..83bf248 100644
--- a/sql/tests/test_insert.py
+++ b/sql/tests/test_insert.py
@@ -88,6 +88,6 @@ class TestInsert(unittest.TestCase):
             with_=[w],
             values=w.select())
         self.assertEqual(str(query),
-            'WITH a AS (SELECT * FROM "t1" AS "b") '
-            'INSERT INTO "t" ("c1") SELECT * FROM a AS "a"')
+            'WITH "a" AS (SELECT * FROM "t1" AS "b") '
+            'INSERT INTO "t" ("c1") SELECT * FROM "a" AS "a"')
         self.assertEqual(query.params, ())
diff --git a/sql/tests/test_select.py b/sql/tests/test_select.py
index 6fbea26..1e17ed1 100644
--- a/sql/tests/test_select.py
+++ b/sql/tests/test_select.py
@@ -249,6 +249,6 @@ class TestSelect(unittest.TestCase):
 
         query = w.select(with_=[w])
         self.assertEqual(str(query),
-            'WITH a AS (SELECT "b"."c1" FROM "t" AS "b") '
-            'SELECT * FROM a AS "a"')
+            'WITH "a" AS (SELECT "b"."c1" FROM "t" AS "b") '
+            'SELECT * FROM "a" AS "a"')
         self.assertEqual(query.params, ())
diff --git a/sql/tests/test_update.py b/sql/tests/test_update.py
index a1cbb3c..0eb4592 100644
--- a/sql/tests/test_update.py
+++ b/sql/tests/test_update.py
@@ -80,7 +80,7 @@ class TestUpdate(unittest.TestCase):
             with_=[w],
             values=[w.select(w.c3, where=w.c4 == 2)])
         self.assertEqual(str(query),
-            'WITH b AS (SELECT "c"."c1" FROM "t1" AS "c") '
-            'UPDATE "t" SET "c2" = (SELECT "b"."c3" FROM b AS "b" '
+            'WITH "b" AS (SELECT "c"."c1" FROM "t1" AS "c") '
+            'UPDATE "t" SET "c2" = (SELECT "b"."c3" FROM "b" AS "b" '
             'WHERE ("b"."c4" = %s))')
         self.assertEqual(query.params, (2,))
diff --git a/sql/tests/test_with.py b/sql/tests/test_with.py
index 487c722..3fb8ed3 100644
--- a/sql/tests/test_with.py
+++ b/sql/tests/test_with.py
@@ -40,7 +40,7 @@ class TestWith(unittest.TestCase):
                     where=self.table.id == 1))
 
             self.assertEqual(simple.statement(),
-                'a AS ('
+                '"a" AS ('
                 'SELECT "b"."id" FROM "t" AS "b" WHERE ("b"."id" = %s)'
                 ')')
             self.assertEqual(simple.statement_params(), (1,))
@@ -50,7 +50,7 @@ class TestWith(unittest.TestCase):
             second = With('a', query=self.table.select(self.table.a))
 
             self.assertEqual(second.statement(),
-                'a("a") AS ('
+                '"a"("a") AS ('
                 'SELECT "b"."a" FROM "t" AS "b"'
                 ')')
             self.assertEqual(second.statement_params(), ())
@@ -65,10 +65,10 @@ class TestWith(unittest.TestCase):
 
             wq = WithQuery(with_=[simple, second])
             self.assertEqual(wq._with_str(),
-                'WITH a AS ('
+                'WITH "a" AS ('
                 'SELECT "b"."id" FROM "t" AS "b" WHERE ("b"."id" = %s)'
-                '), c AS ('
-                'SELECT * FROM a AS "a"'
+                '), "c" AS ('
+                'SELECT * FROM "a" AS "a"'
                 ') ')
             self.assertEqual(wq._with_params(), (1,))
 
@@ -82,9 +82,9 @@ class TestWith(unittest.TestCase):
 
         q = upto10.select(with_=[upto10])
         self.assertEqual(str(q),
-            'WITH RECURSIVE a("n") AS ('
+            'WITH RECURSIVE "a"("n") AS ('
             'VALUES (%s) '
             'UNION ALL '
-            'SELECT ("a"."n" + %s) FROM a AS "a" WHERE ("a"."n" < %s)'
-            ') SELECT * FROM a AS "a"')
+            'SELECT ("a"."n" + %s) FROM "a" AS "a" WHERE ("a"."n" < %s)'
+            ') SELECT * FROM "a" AS "a"')
         self.assertEqual(q.params, (1, 1, 100))
-- 
python-sql



More information about the tryton-debian-vcs mailing list