Mike Bayer committed d301a04

- fixed "ambiguous column" result detection, when dupe col names exist
in a result [ticket:657]

Comments (0)

Files changed (3)

     - 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


                 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.__props[i] = rec


         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 =