Skip to content
This repository was archived by the owner on Aug 19, 2025. It is now read-only.

support render_postcompile - #378

Merged
aminalaee merged 2 commits into
masterfrom
support-render-postcompile
Sep 2, 2021
Merged

aminalaee merged 2 commits into
masterfrom
support-render-postcompile

Conversation

@aminalaee

@aminalaee aminalaee commented Aug 31, 2021 •

Copy link
Copy Markdown
Contributor

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, PrettyWood, rafalp and vmarkovtsev August 31, 2021 06:17

@PrettyWood PrettyWood left a comment

Copy link
Copy Markdown
Contributor

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 subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Development

Successfully merging this pull request may close these issues.

SQLAChemy 1.4 POSTCOMPILE error

2 participants