rails / arel

A Relational Algebra
2.06k stars 390 forks source link

for sqlite, multiple union sub-queries are emitted grouped (parens) which sqlite can not handle #418

Closed bughit closed 6 years ago

bughit commented 8 years ago

https://github.com/brianhempel/active_record_union/pull/4#issuecomment-198833562

using gem 'active_record_union', github: 'odedniv/active_record_union' with sqlite

Post.where(id: 1).union(Post.where(id: 2), Post.where(id: 3), Post.where(id: 4)).to_sql

produces

SELECT "posts".* FROM (
  (
    (
      SELECT "posts".* FROM "posts" WHERE "posts"."user_id" = 1
      UNION
      SELECT "posts".* FROM "posts" WHERE "posts"."id" = 2
    )
    UNION
    SELECT "posts".* FROM "posts" WHERE "posts"."id" = 3
  )
  UNION
  SELECT "posts".* FROM "posts" WHERE "posts"."id" = 4
) "posts"
matthewd commented 6 years ago

Per #523, Arel development is moving to rails/rails.

If this issue is still relevant, please consider reopening it over there. (Note that the Rails repository does not accept feature request issues, and requires reproduction steps that rely on Active Record's documented API.)

kbrock commented 5 years ago

Fix has been merged into Rails