Sophie

Sophie

distrib > Fedora > 16 > i386 > by-pkgid > 0b5557f6be7349be5d3891ffedd05215 > files > 4

python-sqlamp-0.5.2-2.fc16.src.rpm

diff -r 7beb2c6cf64b -r 964320ab0ff5 CHANGES
--- a/CHANGES	Mon Jan 24 00:24:03 2011 +0300
+++ b/CHANGES	Tue Feb 15 21:57:02 2011 +0100
@@ -2,6 +2,8 @@
 -------------------------
 - Fixed support of SQLAlchemy 0.6.6 in :meth:`MPOptions.order_by_clause`.
   Patch by Josip Delic.
+- Workaround for bug in sqlite 3.6.x (problems with binding two integer
+  attributes). Initial patch by Josip Delic.
 
 0.5.2: released 2010-09-19
 --------------------------
diff -r 7beb2c6cf64b -r 964320ab0ff5 sqlamp/__init__.py
--- a/sqlamp/__init__.py	Mon Jan 24 00:24:03 2011 +0300
+++ b/sqlamp/__init__.py	Tue Feb 15 21:57:02 2011 +0100
@@ -237,14 +237,14 @@
             # `tree_id` is next unused integer value,
             # `depth` for root nodes is equal to zero,
             # `path` should be empty string.
-            query = self.session.execute(sqlalchemy.select([
-                (sqlalchemy.func.coalesce(
-                    sqlalchemy.func.max(opts.tree_id_field), 0)
-                 + 1).label('tree_id')
-            ])).fetchone()
-            self._query_result = dict(
-                path='', depth=0, tree_id=query['tree_id']
-            )
+            [tree_id] = self.session.execute(
+                sqlalchemy.func.max(opts.tree_id_field)
+            ).fetchone()
+            if tree_id is None:
+                tree_id = 1
+            else:
+                tree_id += 1
+            self._query_result = dict(path='', depth=0, tree_id=tree_id)
         else:
             # a new instance has at least one ancestor.
             # `tree_id` can be used from parent's value,