From: Mike Bayer Date: Mon, 8 Oct 2012 18:41:35 +0000 (-0400) Subject: - [feature] Various API tweaks to the "dialect" X-Git-Tag: rel_0_8_0b1~75 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=0a6e2d9b3683cf198b7a5bcf34a7abfb1f6ca19a;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git - [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. --- diff --git a/CHANGES b/CHANGES index 33bf4107c9..af63a09600 100644 --- 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 _ instead diff --git a/lib/sqlalchemy/engine/default.py b/lib/sqlalchemy/engine/default.py index 21e02fcdc2..f43c0404e6 100644 --- a/lib/sqlalchemy/engine/default.py +++ b/lib/sqlalchemy/engine/default.py @@ -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. diff --git a/lib/sqlalchemy/engine/result.py b/lib/sqlalchemy/engine/result.py index bf6410f155..9fb735f468 100644 --- a/lib/sqlalchemy/engine/result.py +++ b/lib/sqlalchemy/engine/result.py @@ -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) diff --git a/lib/sqlalchemy/sql/compiler.py b/lib/sqlalchemy/sql/compiler.py index d3a4a64a20..cc41e61825 100644 --- a/lib/sqlalchemy/sql/compiler.py +++ b/lib/sqlalchemy/sql/compiler.py @@ -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, diff --git a/lib/sqlalchemy/testing/plugin/noseplugin.py b/lib/sqlalchemy/testing/plugin/noseplugin.py index 0dcd45825f..1651886b89 100644 --- a/lib/sqlalchemy/testing/plugin/noseplugin.py +++ b/lib/sqlalchemy/testing/plugin/noseplugin.py @@ -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())))