Skip to content

Preserve Arel expressions across query boundaries - #591

Merged
nertzy merged 1 commit into
arel/quoted-valuesfrom
arel/expression-boundaries
Sep 7, 2026
Merged

nertzy merged 1 commit into
arel/quoted-valuesfrom
arel/expression-boundaries

Conversation

@nertzy

@nertzy nertzy commented Sep 7, 2026

Copy link
Copy Markdown
Collaborator

Keep expressions as Arel nodes across normalization, ranking, and association joins instead of rendering and wrapping them again.

Normalizer previously recognized node subclasses but not Arel attributes, which are separate objects. Passing an attribute turned its Ruby inspection into SQL. Preserve attributes alongside nodes, retain trusted String SQL input, and reject unsupported objects rather than silently stringifying them.

The default rank now remains an expression. Association exposes an Arel join consumed directly by scope construction, allowing scoped bind values to travel through Active Record's collector. The existing String join adapter still renders through the unprepared path, and custom ranking/ordering SQL remains supported.

Public examples exercise attribute normalization, node-based joins, NULL aggregation, scoped conditions containing quotes, and the legacy String adapter. The empty-source tsearch fragment remains unchanged: removing it changes existing failure behavior and would require a separate validation decision.

Continues above #590 without changing the earlier review heads.

@nertzy
nertzy force-pushed the arel/expression-boundaries branch from eb178d7 to 69aebc8 Compare September 7, 2026 15:05
@nertzy
nertzy force-pushed the arel/expression-boundaries branch from 69aebc8 to b7eac02 Compare September 7, 2026 17:39
@nertzy
nertzy force-pushed the arel/expression-boundaries branch from b7eac02 to a98d3db Compare September 7, 2026 17:44
@nertzy
nertzy force-pushed the arel/expression-boundaries branch 2 times, most recently from 3d1215f to dd5704f Compare September 7, 2026 18:32
@nertzy
nertzy force-pushed the arel/expression-boundaries branch from dd5704f to eff2975 Compare September 7, 2026 18:55
Keep attributes intact during normalization and reject unsupported inputs
instead of treating Ruby inspection text as SQL. Preserve trusted String
input and quoted-value nodes.

Carry default rank, association primary keys, and internal joins as nodes.
Keep custom ranking SQL and the bind-safe legacy String join adapter.
@nertzy
nertzy force-pushed the arel/expression-boundaries branch from eff2975 to c47e272 Compare September 7, 2026 20:46
@nertzy
nertzy merged commit c47e272 into master Sep 7, 2026
13 checks passed
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.

1 participant