]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- Oracle will detect string-based statements which contain
authorMike Bayer <mike_mp@zzzcomputing.com>
Tue, 7 Oct 2008 16:58:53 +0000 (16:58 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Tue, 7 Oct 2008 16:58:53 +0000 (16:58 +0000)
      comments at the front before a SELECT as SELECT statements.
      [ticket:1187]

CHANGES
lib/sqlalchemy/databases/oracle.py
test/dialect/oracle.py

diff --git a/CHANGES b/CHANGES
index 3ad0f12c06ff04c461b9e2c22509352e2fd40114..22e96cafc00f664d6497162bff5eb9d48b2f6d41 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -74,7 +74,10 @@ CHANGES
 - mysql
     - Temporary tables are now reflectable.
 
-
+- oracle
+    - Oracle will detect string-based statements which contain 
+      comments at the front before a SELECT as SELECT statements.
+      [ticket:1187]
 0.5.0rc1
 ========
 
index 3f5077d1aeee05fc03ea97eb2f58aa3a078393f9..eb02d4505190a92cb71e24bb9f3cabfc4960aaf4 100644 (file)
@@ -14,6 +14,8 @@ from sqlalchemy.sql import operators as sql_operators, functions as sql_function
 from sqlalchemy import types as sqltypes
 
 
+SELECT_REGEXP = re.compile(r'(\s*/\*\+.*?\*/)?\s*SELECT', re.I | re.UNICODE)
+
 class OracleNumeric(sqltypes.Numeric):
     def get_col_spec(self):
         if self.precision is None:
@@ -206,6 +208,9 @@ class OracleExecutionContext(default.DefaultExecutionContext):
                     self.out_parameters[name] = self.cursor.var(dbtype)
                     self.parameters[0][name] = self.out_parameters[name]
 
+    def returns_rows_text(self, statement):
+        return SELECT_REGEXP.match(statement)
+
     def create_cursor(self):
         c = self._connection.connection.cursor()
         if self.dialect.arraysize:
index ac52b26a989c47364378605fbd414dbaa0283450..6803508f5bc1f1a5fce154349c30a74d36669a0e 100644 (file)
@@ -356,6 +356,10 @@ class SequenceTest(TestBase, AssertsCompiledSQL):
         seq = Sequence("My_Seq", schema="Some_Schema")
         assert dialect.identifier_preparer.format_sequence(seq) == '"Some_Schema"."My_Seq"'
 
+class ExecuteTest(TestBase):
+    __only_on__ = 'oracle'
+    def test_basic(self):
+        assert testing.db.execute("/*+ this is a comment */ SELECT 1 FROM DUAL").fetchall() == [(1,)]
 
 if __name__ == '__main__':
     testenv.main()