Skip to content

Record proxy with type result processors #45

@achimnol

Description

@achimnol

Regarding #42 (which applies the type bind processors when adding parameters to the queries), I found that the reverse direction is not working yet — the type result processors (both for user-defined type decroators and dialect-specific types) are not invoked when reading the fetched rows.

I tried to fix this by myself, but it seems to be much more complicated than I first thought:

  • It requires major rewriting of the current SAConnection class so that compiled._result_columns are passed around. This is not trivial because we currently subclasses asyncpg.connection.Connection directly and extends its API by overrides, e.g., we need to know which methods are invoked by who (either the base class or our class).
  • Record and RecordGenerator classes should have reference to both the compiled._result_columns and _dialect.dbapi_type_map. So Record is no longer just a thin wrapper of the given "row" dict but an active post-processor of row fields, like in aiopg.
  • Whenever accessing the row values, we need to lookup and apply result processors based on the above two maps.

For custom types, maybe I need to fall back to aiopg for more complete SA functionality due to my time limits. It is unfortunate not to have public/documented SQLAlchemy APIs to make low-level adaptor libraries like asyncpgsa and aiopg. 😢

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions