BuffferedColumnResultProxy with compiled_cache corrupts result metadata

Issue #3699 resolved
Mike Bayer repo owner created an issue
from sqlalchemy import create_engine, select, TypeDecorator, String, literal
from sqlalchemy.engine import default
from sqlalchemy.engine import result


class ExcCtx(default.DefaultExecutionContext):

    def get_result_proxy(self):
        return result.BufferedColumnResultProxy(self)

engine = create_engine("sqlite://")
engine.dialect.execution_ctx_cls = ExcCtx


class MyType(TypeDecorator):
    impl = String()

    def process_result_value(self, value, dialect):
        return "HI " + value

with engine.connect() as conn:
    stmt = select([literal("THERE", type_=MyType())])
    for i in range(2):
        r = conn.execute(stmt)
        assert r.scalar() == "HI THERE"

with engine.connect() as conn:
    cache = {}
    conn = conn.execution_options(compiled_cache=cache)

    stmt = select([literal("THERE", type_=MyType())])
    for i in range(2):
        r = conn.execute(stmt)
        assert r.scalar() == "HI THERE"

Comments (3)

  1. Mike Bayer reporter

    Don't double-process ResultMetaData for BufferedColumnResultProxy

    Fixed a bug in the result proxy used mainly by Oracle when binary and other LOB types are in play, such that when query / statement caching were used, the type-level result processors, notably that required by the binary type itself but also any other processor, would become lost after the first run of the statement due to it being removed from the cached result metadata.

    Change-Id: I751940866cffb4f48de46edc8137482eab59790c Fixes: #3699

    → <<cset f3bc60bdd809>>

  2. Mike Bayer reporter

    Don't double-process ResultMetaData for BufferedColumnResultProxy

    Fixed a bug in the result proxy used mainly by Oracle when binary and other LOB types are in play, such that when query / statement caching were used, the type-level result processors, notably that required by the binary type itself but also any other processor, would become lost after the first run of the statement due to it being removed from the cached result metadata.

    Change-Id: I751940866cffb4f48de46edc8137482eab59790c Fixes: #3699 (cherry picked from commit f3bc60bdd809235cbeb3f414717ac0e273269cf9)

    → <<cset c2505259531d>>

  3. Log in to comment