]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
oracle can conditionally decide if it wants to say "use rowid" in a select statement.
authorMike Bayer <mike_mp@zzzcomputing.com>
Wed, 24 Jan 2007 03:21:26 +0000 (03:21 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Wed, 24 Jan 2007 03:21:26 +0000 (03:21 +0000)
needs to be tweaked vs. when ROW NUMBER OVER ORDER BY is being used, but currently
fixes [ticket:436]

lib/sqlalchemy/ansisql.py
lib/sqlalchemy/databases/oracle.py
lib/sqlalchemy/databases/postgres.py
lib/sqlalchemy/databases/sqlite.py
lib/sqlalchemy/engine/base.py
lib/sqlalchemy/engine/default.py

index 69b082e41468041e30f1772c2a17731d291401d6..803cba6d32f34688e851d27b12fb64adb0717d37 100644 (file)
@@ -215,7 +215,7 @@ class ANSICompiler(sql.Compiled):
             self.strings[column] = self.preparer.format_column(column)
         else:
             if column.table.oid_column is column:
-                n = self.dialect.oid_column_name()
+                n = self.dialect.oid_column_name(column)
                 if n is not None:
                     self.strings[column] = "%s.%s" % (self.preparer.format_table(column.table, use_schema=False), n)
                 elif len(column.table.primary_key) != 0:
index 6008ae61c9c5abca78dc59c483e144c8f4034a7d..b5bd72e8f218907380f1821ff6772248855150b9 100644 (file)
@@ -192,8 +192,11 @@ class OracleDialect(ansisql.ANSIDialect):
     def type_descriptor(self, typeobj):
         return sqltypes.adapt_type(typeobj, colspecs)
 
-    def oid_column_name(self):
-        return "rowid"
+    def oid_column_name(self, column):
+        if not isinstance(column.table, sql.TableClause) and not isinstance(column.table, sql.Select):
+            return None
+        else:
+            return "rowid"
 
     def create_execution_context(self):
         return OracleExecutionContext(self)
index e3ac3ae2c6b31d3c5256500f8318c640082da0c1..7eee35320f51fab2028fdbaa5f102db7ab6ee4a7 100644 (file)
@@ -279,7 +279,7 @@ class PGDialect(ansisql.ANSIDialect):
         else:
             return self.context.last_inserted_ids
 
-    def oid_column_name(self):
+    def oid_column_name(self, column):
         if self.use_oids:
             return "oid"
         else:
index 6d1e56a7c730cc4dee11fb90f6d2e0113f994210..dda488f9c01c01c02c2332ca3969778ff0bbe44c 100644 (file)
@@ -165,7 +165,7 @@ class SQLiteDialect(ansisql.ANSIDialect):
     def last_inserted_ids(self):
         return self.context.last_inserted_ids
     
-    def oid_column_name(self):
+    def oid_column_name(self, column):
         return "oid"
 
     def dbapi(self):
index 77ab866c71f90e980396adc7f8ef41125dce9215..c7b5d93fe68220925cd7473d0ddb91ef826756ac 100644 (file)
@@ -52,8 +52,13 @@ class Dialect(sql.AbstractDialect):
         which comes from the types module.  Subclasses will usually use the adapt_type()
         method in the types module to make this job easy."""
         raise NotImplementedError()
-    def oid_column_name(self):
-        """returns the oid column name for this dialect, or None if the dialect cant/wont support OID/ROWID."""
+    def oid_column_name(self, column):
+        """return the oid column name for this dialect, or None if the dialect cant/wont support OID/ROWID.
+        
+        the Column instance which represents OID for the query being compiled is passed, so that the dialect
+        can inspect the column and its parent selectable to determine if OID/ROWID is not selected for a particular
+        selectable (i.e. oracle doesnt support ROWID for UNION, GROUP BY, DISTINCT, etc.)
+        """
         raise NotImplementedError()
     def supports_sane_rowcount(self):
         """Provided to indicate when MySQL is being used, which does not have standard behavior
index 94c01f324909807fcffe35605bb726730efd2bdb..06409377cdbcca3d165f21bf7171a0905abca1fb 100644 (file)
@@ -41,7 +41,7 @@ class DefaultDialect(base.Dialect):
         if type(typeobj) is type:
             typeobj = typeobj()
         return typeobj
-    def oid_column_name(self):
+    def oid_column_name(self, column):
         return None
     def supports_sane_rowcount(self):
         return True