Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Record proxy with type result processors #45

Open
achimnol opened this issue Aug 22, 2017 · 2 comments
Open

Record proxy with type result processors #45

achimnol opened this issue Aug 22, 2017 · 2 comments

Comments

@achimnol
Copy link
Contributor

achimnol commented Aug 22, 2017

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. 😢

@achimnol achimnol changed the title Result/row proxies for TypeDecorator result processors Result/row proxies for type result processors Aug 22, 2017
@achimnol achimnol changed the title Result/row proxies for type result processors Record proxy with type result processors Aug 22, 2017
@nhumrich
Copy link
Contributor

I might be able to figure this out. I think you gave me enough information to pursue it.

@nhumrich
Copy link
Contributor

So... 6 months later, it looks like I havent dug into this. I would love to, but apparently havent been able to find the time. I am adding this to my official backlog to hope I get to it. But in the meantime, PR's would be helpful if this is important for anyone.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants