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

build(deps): switch to sqlalchemy 1.4 #299

Merged
merged 2 commits into from Aug 26, 2021

Conversation

PrettyWood
Copy link
Member

@PrettyWood PrettyWood commented Mar 15, 2021

Sqlalchemy 1.4 is out with some breaking changes (e.g. RowProxy got removed in favor of Row or the removal of row.values() in favor of row._mapping.values())

closes #298 and closes #348

@PrettyWood PrettyWood force-pushed the fix/sqlalchemy-1.4 branch 2 times, most recently from 89ab2b9 to 8aa58f3 Compare March 16, 2021 10:31
@PrettyWood PrettyWood changed the title fix: support sqlalchemy 1.4 build(deps): switch to sqlalchemy 1.4 Mar 16, 2021
return self._row.values()
@property
def _mapping(self) -> asyncpg.Record:
return self._row
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like your insight on this matter.

For postgres, row.values() was still working thanks to this Record class but for all other backends we now need to do row._mapping.values() with sqlalchemy >= 1.4

Do we want to:

  1. keep values() only for postgres
  2. keep values() for all backends and we can attach the deprecated property to the sqlalchemy.Row class
  3. let it like this and mimic sqlalchemy API also for postgres

Thanks for this very nice lib!

Copy link

@ansipunk ansipunk May 6, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

imo It'd be better to keep row.values() for all backends since looking at test changes I can see that row.keys() is still present so row._mapping.values() would bring an inconsistency.

Although it's sorta weird they kept row.keys() but got rid of row.values() in favor of row._mapping.values(). I think you could try row._asdict() as suggested here in SQLAlchemy issue related to 1.4.

SQLAlchemy documentation says row.keys() is deprecated in favor of row._mapping() so I suppose you have to add row.mapping() for all backends.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm I don't really want to add row.values() for all backends since it would need some monkeypatching or wrapper around the SQLAlchemy objects.
I reckon the idea of databases is to keep things simple and to stay close to SQLAlchemy when possible.
This is why I went with updating postgres backend only to mimic SQLAlchemy behaviour.
But honestly I don't have a strong opinion on this so if people really want values(), keys() back, we can recreate the wrapper RowProxy

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My bad, I started my comment with keep since that inconsistency was triggering me, although after reading SQLAlchemy's changelogs and docs I immediately changed my mind about keeping values but did not change the original paragraph.

I do agree with decision to keep the API as close to SQLAlchemy's as possible.

Just that test having both row.values and row._mapping.keys misled me.

@uSpike
Copy link
Member

uSpike commented Mar 26, 2021

setup.py needs to be updated to specify install_requires=["sqlalchemy>=1.4,<2", ... or a similar constraint.

@tomchristie
Copy link
Member

New release 0.4.3 to properly pin SQLAlchemy until this PR is resolved. https://pypi.org/project/databases/

(This PR should update the pin to <1.5, so we don't get bitten again.)

@PrettyWood
Copy link
Member Author

@tomchristie do we want to support both 1.3 and 1.4 or 1.4 only?

@tomchristie
Copy link
Member

Ideally both, at least for a time. (But if that was really awkward I guess we could consider just 1.4, with some clear notes for users on which older version of databases to use for 1.3 etc)

@PrettyWood
Copy link
Member Author

@tomchristie Ok no problem. Is it ok if I update CI pipeline to run all tests with both versions?

@ansipunk
Copy link

ansipunk commented May 5, 2021

I guess dropping support for 1.3 is okay since pip 's new dependency resolver would automatically download an older version of databases if the user's environment requires SQLAlchemy 1.3.

An ugly solution to support both 1.3 and 1.4 can be seen here in SQLAlchemy-Utils 0.37.

@tomchristie
Copy link
Member

@Euromance Fair point. I'm okay with requiring 1.4+ then.

@PrettyWood
Copy link
Member Author

Cool! I'll get back on it next Thursday when I have more time

Copy link

@ansipunk ansipunk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess you could also test that deprecated methods throw their warnings

@PrettyWood
Copy link
Member Author

@Euromance Yes it was planned thanks 👍 I first wanted to have your feedback on the interface. Glad we agree! Coverage should be good now

@nikolayanguelov
Copy link

Do you guys have any update on the ETA on when this might get merged and released to the public?

Thank you!

@pvicente
Copy link

Hi, is there any plan to merge this PR? When are you planning to do a release with sqlalchemy >= 1.4 support? 🙏🏼

@tomchristie
Copy link
Member

@PrettyWood If you'd like to get this in then let me know and can add you to the maintainers team, and walk you through the release process.

@PrettyWood
Copy link
Member Author

With pleasure @tomchristie!

@tomchristie
Copy link
Member

@PrettyWood - Okay, I've sent you an invite. I'll leave getting this reviewed/merged/conflict resolved/whatever up to you - tho let us know if you need anything. Then once that's done let's walk through how you can roll a release.

@PrettyWood
Copy link
Member Author

@tomchristie I rebased on master. I'll wait for a review from a member. If everything is fine, I feel like the release process is straightforward (PR to bump version with changelog update + tag that triggers github worfklow to publish on pypi). Am I missing something?

setup.py Show resolved Hide resolved
@ghost
Copy link

ghost commented Aug 24, 2021

Is this ready to be merged? Thank you!

@Feijo
Copy link

Feijo commented Aug 24, 2021

I am also waiting for this release

@aminalaee
Copy link
Member

@PrettyWood Do you want to make any other changes or are you waiting for more reviewers?

@PrettyWood
Copy link
Member Author

Hi @aminalaee
I don't plan to add anything more. If we feel like 1 review is enough then we can merge :)

@aminalaee
Copy link
Member

Hi, @PrettyWood
I did go over this again and everything looks good. I think we can merge this and prepare the release #370

@aminalaee aminalaee merged commit 89efe60 into encode:master Aug 26, 2021
@PrettyWood PrettyWood deleted the fix/sqlalchemy-1.4 branch August 26, 2021 16:33
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

Successfully merging this pull request may close these issues.

when can we expect the support for SQLAlchemy >=1.4? Broken RowProxy import with sqlalchemy 1.4
9 participants