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

[WIP] It breaks when prepared statements are disabled #21

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

andrepiske
Copy link
Collaborator

@andrepiske andrepiske commented Jan 30, 2025

When ActiveRecord SQL Query Comments is enabled, AR will automatically disable prepared statements.

Without prepared statements, a test breaks like here: https://github.com/trusted/iron_trail/actions/runs/13052410073/job/36415455364

The fix is easy and just constitutes in converting the incoming value to a string, since the ->> JSON operator in PostgreSQL always returns a string, no matter the value type in the json object.

I don't know how to properly test this, so I'm leaving it here for now.


The fix could be just to change the line at `` from:

# breaks:
::Arel::Nodes::BindParam.new(value)

# works:
::Arel::Nodes::BindParam.new(value.to_s)

but what if value is nil?


Asana link

@andrepiske andrepiske self-assigned this Jan 30, 2025
@andrepiske andrepiske changed the title [WIP] enable AR sql query comments [WIP] It breaks when prepared statements are disabled Jan 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant