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

support render_postcompile #378

Merged
merged 2 commits into from
Sep 2, 2021
Merged

support render_postcompile #378

merged 2 commits into from
Sep 2, 2021

Conversation

aminalaee
Copy link
Member

@aminalaee aminalaee commented Aug 31, 2021

Fixes #377

The behavior of IN and NOT IN Bind parameters have changed to POSTCOMPILE which will expand parameters on the fly.

SQLAlchemy changelog here.

stmt = select(A.id, A.data).where(A.id.in_([1, 2, 3]))

>>> print(stmt)
SELECT a.id, a.data
FROM a
WHERE a.id IN ([POSTCOMPILE_id_1])

We should either use literal_binds with compile:

>>> print(stmt.compile(compile_kwargs={"literal_binds": True}))
SELECT a.id, a.data
FROM a
WHERE a.id IN (1, 2, 3)

Or use new render_postcompile helper:

>>> print(stmt.compile(compile_kwargs={"render_postcompile": True}))
SELECT a.id, a.data
FROM a
WHERE a.id IN (:id_1_1, :id_1_2, :id_1_3)

@aminalaee aminalaee requested review from a team, vmarkovtsev, PrettyWood and rafalp August 31, 2021 06:17
Copy link
Member

@PrettyWood PrettyWood left a comment

Choose a reason for hiding this comment

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

Thanks for that!
I guess a 0.5.1 should be done

@aminalaee aminalaee merged commit 1f7ca7b into master Sep 2, 2021
@aminalaee aminalaee deleted the support-render-postcompile branch September 2, 2021 08:04
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.

SQLAChemy 1.4 POSTCOMPILE error
2 participants