Commits

Mike Bayer committed d001a39

a few oracle fixes

  • Participants
  • Parent commits 4576c7a

Comments (0)

Files changed (5)

File lib/sqlalchemy/dialects/oracle/base.py

         columnlist = list(expression._select_iterables(returning_cols))
 
         columns = [
-                self._label_select_column(None, c, True, False, {})
+                self._label_select_column(None, c, True, False, {},
+                                            within_columns_clause=False)
                 for c in columnlist
             ]
 

File lib/sqlalchemy/sql/compiler.py

             self.result_map[keyname] = name, objects, type_
 
     def _label_select_column(self, select, column, populate_result_map,
-                                    asfrom, column_clause_args):
+                                    asfrom, column_clause_args,
+                                    within_columns_clause=True):
         """produce labeled columns present in a select()."""
 
         if column.type._has_column_expression:
             result_expr = col_expr
 
         return result_expr._compiler_dispatch(
-                       self, within_columns_clause=True,
+                       self, within_columns_clause=within_columns_clause,
                         add_to_result_map=add_to_result_map,
                         **column_clause_args
                     )

File test/dialect/test_oracle.py

                 "t1.c2, t1.c3 INTO :ret_0, :ret_1"
         )
 
+    def test_returning_insert_labeled(self):
+        t1 = table('t1', column('c1'), column('c2'), column('c3'))
+        self.assert_compile(
+            t1.insert().values(c1=1).returning(t1.c.c2.label('c2_l'), t1.c.c3.label('c3_l')),
+            "INSERT INTO t1 (c1) VALUES (:c1) RETURNING "
+                "t1.c2, t1.c3 INTO :ret_0, :ret_1"
+        )
+
     def test_compound(self):
         t1 = table('t1', column('c1'), column('c2'), column('c3'))
         t2 = table('t2', column('c1'), column('c2'), column('c3'))

File test/orm/inheritance/test_basic.py

     @classmethod
     def define_tables(cls, metadata):
         Table('a', metadata,
-                Column('id', Integer, primary_key=True),
+                Column('id', Integer, primary_key=True,
+                                    test_needs_autoincrement=True),
                 Column('b_id', Integer,
                         ForeignKey('b.id', use_alter=True, name='b'))
             )

File test/orm/test_of_type.py

             sess.query(Company.company_id).\
                 filter(
                     Company.employees.of_type(wp).any(
-                            wp.Engineer.primary_language=='java')
+                            wp.Engineer.primary_language == 'java')
                 ).all(),
             [(1, )]
         )
         class Job(ComparableEntity, Base):
             __tablename__ = "job"
 
-            id = Column(Integer, primary_key=True)
+            id = Column(Integer, primary_key=True,
+                                        test_needs_autoincrement=True)
             type = Column(String(10))
             container_id = Column(Integer, ForeignKey('data_container.id'))
-            __mapper_args__ = {"polymorphic_on":type}
+            __mapper_args__ = {"polymorphic_on": type}
 
         class SubJob(Job):
             __tablename__ = 'subjob'
             id = Column(Integer, ForeignKey('job.id'), primary_key=True)
             attr = Column(String(10))
-            __mapper_args__ = {"polymorphic_identity":"sub"}
+            __mapper_args__ = {"polymorphic_identity": "sub"}
 
         class ParentThing(ComparableEntity, Base):
             __tablename__ = 'parent'
-            id = Column(Integer, primary_key=True)
+            id = Column(Integer, primary_key=True,
+                                            test_needs_autoincrement=True)
             container_id = Column(Integer, ForeignKey('data_container.id'))
             container = relationship("DataContainer")
 
         class DataContainer(ComparableEntity, Base):
             __tablename__ = "data_container"
 
-            id = Column(Integer, primary_key=True)
+            id = Column(Integer, primary_key=True,
+                                            test_needs_autoincrement=True)
             name = Column(String(10))
             jobs = relationship(Job, order_by=Job.id)