]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- [feature] Various API tweaks to the "dialect"
authorMike Bayer <mike_mp@zzzcomputing.com>
Mon, 8 Oct 2012 18:41:35 +0000 (14:41 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Mon, 8 Oct 2012 18:41:35 +0000 (14:41 -0400)
    API to better support highly specialized
    systems such as the Akiban database, including
    more hooks to allow an execution context to
    access type processors.

CHANGES
lib/sqlalchemy/engine/default.py
lib/sqlalchemy/engine/result.py
lib/sqlalchemy/sql/compiler.py
lib/sqlalchemy/testing/plugin/noseplugin.py

diff --git a/CHANGES b/CHANGES
index 33bf4107c9c2a76b8c88104cc03ac45494ed9415..af63a096003f0b4c06410737ec6f05b096d29536 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -423,6 +423,12 @@ underneath "0.7.xx".
     collection of bound parameters, rather than
     implicitly assigning None. [ticket:2556]
 
+  - [feature] Various API tweaks to the "dialect"
+    API to better support highly specialized
+    systems such as the Akiban database, including
+    more hooks to allow an execution context to
+    access type processors.
+
   - [bug] The names of the columns on the
     .c. attribute of a select().apply_labels()
     is now based on <tablename>_<colkey> instead
index 21e02fcdc2f07f2d1b8c644d5c7fb24fe3182662..f43c0404e6d8ea8b2af3a09eca75dd5669ec4bac 100644 (file)
@@ -625,6 +625,16 @@ class DefaultExecutionContext(interfaces.ExecutionContext):
     def post_exec(self):
         pass
 
+    def get_result_processor(self, type_, colname, coltype):
+        """Return a 'result processor' for a given type as present in
+        cursor.description.
+
+        This has a default implementation that dialects can override
+        for context-sensitive result type handling.
+
+        """
+        return type_._cached_result_processor(self.dialect, coltype)
+
     def get_lastrowid(self):
         """return self.cursor.lastrowid, or equivalent, after an INSERT.
 
index bf6410f155f58056ac4597ec75a2196d15465a75..9fb735f46873b0e428beaf8e07d2f2935b59e951 100644 (file)
@@ -210,7 +210,7 @@ class ResultMetaData(object):
                 name, obj, type_ = \
                         colname, None, typemap.get(coltype, types.NULLTYPE)
 
-            processor = type_._cached_result_processor(dialect, coltype)
+            processor = context.get_result_processor(type_, colname, coltype)
 
             processors.append(processor)
             rec = (processor, obj, i)
index d3a4a64a20fa8b2729c9523cb434eaeba5098b2d..cc41e61825ca0cf261780275c0e1710010cdb2ac 100644 (file)
@@ -1068,6 +1068,7 @@ class SQLCompiler(engine.Compiled):
     def visit_select(self, select, asfrom=False, parens=True,
                             iswrapper=False, fromhints=None,
                             compound_index=0,
+                            force_result_map=False,
                             positional_names=None, **kwargs):
         entry = self.stack and self.stack[-1] or {}
 
@@ -1082,9 +1083,11 @@ class SQLCompiler(engine.Compiled):
         # to outermost if existingfroms: correlate_froms =
         # correlate_froms.union(existingfroms)
 
-        populate_result_map = compound_index == 0 and (
-                                not entry or \
-                                entry.get('iswrapper', False)
+        populate_result_map = force_result_map or (
+                                compound_index == 0 and (
+                                    not entry or \
+                                    entry.get('iswrapper', False)
+                                )
                             )
 
         self.stack.append({'from': correlate_froms,
index 0dcd45825f7240fa0ddb9c8821f7170ef0a1673e..1651886b896ba8e0e4bf69411243c3a43af3096b 100644 (file)
@@ -158,13 +158,23 @@ def _prep_testing_database(options, file_config):
         e = engines.utf8_engine()
         inspector = inspect(e)
 
-        for vname in inspector.get_view_names():
-            e.execute(schema._DropView(schema.Table(vname, schema.MetaData())))
+        try:
+            view_names = inspector.get_view_names()
+        except NotImplementedError:
+            pass
+        else:
+            for vname in view_names:
+                e.execute(schema._DropView(schema.Table(vname, schema.MetaData())))
 
-        for vname in inspector.get_view_names(schema="test_schema"):
-            e.execute(schema._DropView(
-                        schema.Table(vname,
-                                    schema.MetaData(), schema="test_schema")))
+        try:
+            view_names = inspector.get_view_names(schema="test_schema")
+        except NotImplementedError:
+            pass
+        else:
+            for vname in view_names:
+                e.execute(schema._DropView(
+                            schema.Table(vname,
+                                        schema.MetaData(), schema="test_schema")))
 
         for tname in reversed(inspector.get_table_names(order_by="foreign_key")):
             e.execute(schema.DropTable(schema.Table(tname, schema.MetaData())))