]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- fixed "ambiguous column" result detection, when dupe col names exist
authorMike Bayer <mike_mp@zzzcomputing.com>
Sun, 15 Jul 2007 15:40:09 +0000 (15:40 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Sun, 15 Jul 2007 15:40:09 +0000 (15:40 +0000)
in a result [ticket:657]

CHANGES
lib/sqlalchemy/engine/base.py
test/sql/query.py

diff --git a/CHANGES b/CHANGES
index cdd08b9069174fe92937386db4990463b257d128..81f0ec33ec12f4a57606c53e942eab9c7b0ee508 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -65,6 +65,8 @@
     - columns can be overridden in a reflected table with a "key" 
       attribute different than the column's name, including for primary key
       columns [ticket:650]
+    - fixed "ambiguous column" result detection, when dupe col names exist
+      in a result [ticket:657]
     - some enhancements to "column targeting", the ability to match a column
       to a "corresponding" column in another selectable.  this affects mostly
       ORM ability to map to complex joins
index 99688a48fd13d4451113e1e24d8127e08933c4e2..dc197eb190bcd011e946129975eb3983555e9b63 100644 (file)
@@ -885,7 +885,7 @@ class ResultProxy(object):
                 if rec[0] is None:
                     raise DBAPIError("None for metadata " + colname)
                 if self.__props.setdefault(colname.lower(), rec) is not rec:
-                    self.__props[colname.lower()] = (ResultProxy.AmbiguousColumn(colname), 0)
+                    self.__props[colname.lower()] = (type, ResultProxy.AmbiguousColumn(colname), 0)
                 self.__keys.append(colname)
                 self.__props[i] = rec
 
index bf781777096780942f71ae2014fae261618ba08e..91587bc0e151208815cc01230abbecb4a15e22b9 100644 (file)
@@ -253,7 +253,16 @@ class QueryTest(PersistTest):
         r = text("select * from query_users where user_id=2", engine=testbase.db).execute().fetchone()
         self.assert_(r.user_id == r['user_id'] == r[self.users.c.user_id] == 2)
         self.assert_(r.user_name == r['user_name'] == r[self.users.c.user_name] == 'jack')
-        
+    
+    def test_ambiguous_column(self):
+        self.users.insert().execute(user_id=1, user_name='john')
+        r = users.outerjoin(addresses).select().execute().fetchone()
+        try:
+            print r['user_id']
+            assert False
+        except exceptions.InvalidRequestError, e:
+            assert str(e) == "Ambiguous column name 'user_id' in result set! try 'use_labels' option on select statement."
+            
     def test_keys(self):
         self.users.insert().execute(user_id=1, user_name='foo')
         r = self.users.select().execute().fetchone()