-
Notifications
You must be signed in to change notification settings - Fork 263
Add _mapping property to the result set interface. #447
Conversation
This will still be breaking comparing to 0.5.3 due to the fact that Record inherits from Sequence. So it should go into 0.6.0 anyway. I'm not a big fan of exposing a private property as it's against PEP8 and will annoy a lot of IDEs and linters, but I assume we want to be in line with SQLAlchemy as of now. |
Should we document the I also don't think documenting the private property would be ideal, but I see the initial issue was about this property being unknown. |
I believe we should document this property as this will be the only way to get a Mapping. We can point to mentioned SA docs to emphasise that we wan't to keep it in line with SA. |
BTW we should probably release a 0.5.5 release reverting the change to keep the 0.5.X line non-breaking so that people with dependencies pinned for i.e. |
Agreed. You mean we should revert #436 for 0.5.5, or something else? |
What I mean is to create a new branch, revert #436 and #408 and publish as 0.5.5 from that branch. Branch with only reverted changes: Draft of the release: @aminalaee can you please review this branch changes as there will be no PR to master to avoid creating a mess |
@collerek That looks good to me. The reason I asked about the change was that I wanted to say you don't need the documentation changes reverted, as for example Not sure how you've tested this, but It might be worth creating a temporary PR for it to make sure all checks will pass and close it later. |
@collerek @aminalaee Hi! |
Yep, missing docs is all we need :) |
Done! I've double checked everything but i'm not a native speaker so feel free to correct any grammar mistakes :) |
Looks good to me. Thank you. |
Co-authored-by: Amin Alaee <[email protected]>
EDIT Okay, I see that this hasn't been released yet, so I am on the old code. I am assuming that this will fix my issue. Are we going to bump a version for this? This is causing mypy to complain: record = await db.fetch_one(users.select().where(users.c.email == email))
return User.parse_obj(record._mapping) # "Mapping[Any, Any]" has no attribute "_mapping" I am using the syntax above due to the deprecation warning raised here (which mypy doesn't complain about): record = await db.fetch_one(users.select().where(users.c.email == email))
return User.parse_obj(record) # DeprecationWarning: The `Row.keys()` method is deprecated
# to mimic SQLAlchemy behaviour, use `Row._mapping.keys()` instead. |
Yes, this will be part of the 0.6.0 release (#444) |
At least with asyncpg, |
Also seeing the same issue as @circlingthesun. |
@theprestigedog I've created a PR (#501) that restores string indexing on Record objects. It's still pending review. |
Still seeing this issue even on
|
Co-authored-by: collerek <[email protected]>
Also seeing this in the 0.7.0 release.
|
Closes #445
As discussed in the main issue i've added
_mapping
property to the result set interface. Both asyncpg Record and sqlalchemy Row have this property so it's safe to add it.