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

Fix compatiblity with SQLAlchemy 1.3 #3958

Closed

Conversation

hrist0stoichev
Copy link
Contributor

@hrist0stoichev hrist0stoichev commented May 2, 2023

Related to this issue and this PR.

It seems there are more thing that depends on sqlalchemy >= 1.4 so I'm fixing those in this PR. Also, locking SQLAlchemy to 1.3.24 so that the build step will fail if something that depends on sqlalchemy >= 1.4 is added.

  1. from sqlalchemy.orm import declarative_base -> from sqlalchemy.ext.declarative import declarative_base
  2. with Session() -> session = Session(); try: ... finally: session.close()
  3. query().where() -> query().filter() - where is synonym for filter in 1.4
  4. select() -> query() - The select API is quite different in 1.3.
  5. exec_driver_sql() -> execute() - this is a synonym in 1.4

I realize this change is becoming quite complex so another approach might be to just revert my previous PR and start depending on sqlalchemy >= 1.4 again but I still think that backwards compatibility is more important for a library so I will just submit this PR for review.

@hrist0stoichev hrist0stoichev marked this pull request as draft May 2, 2023 08:17
@hrist0stoichev hrist0stoichev marked this pull request as ready for review May 2, 2023 09:57
Copy link
Contributor

@hwchase17 hwchase17 left a comment

Choose a reason for hiding this comment

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

im thinking we should just drop support for 1.3

not sure if worth upkeep

@hrist0stoichev
Copy link
Contributor Author

Or maybe make SQLAlchemy an optional dependency? 99% of langchain can be used without it and we are currently at a point where we can't update langchain because we use sqlalchemy 1.3

@ProbableTrain
Copy link

+1 for supporting 1.3, the 1.3 => 1.4 migration isn't easy

@hwchase17
Copy link
Contributor

@hrist0stoichev hows this?

#4647

this changes it so there won't be any errors on import. we could look into making truly optional, but would take a bit more effort

@hwchase17
Copy link
Contributor

(if you want to make truly optional, id accept that pr instead)

@hrist0stoichev
Copy link
Contributor Author

yeah, #4647 looks good enough

@dosubot dosubot bot added Ɑ: memory Related to memory module 🤖:improvement Medium size change to existing code to handle new use-cases labels Jul 14, 2023
@baskaryan
Copy link
Collaborator

sounds like this has been resolved, let me know if i'm missing something!

@baskaryan baskaryan closed this Aug 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🤖:improvement Medium size change to existing code to handle new use-cases Ɑ: memory Related to memory module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants