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

Preserve RECURSIVE flag of CTE relations when they are merged. #189

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Commits on Dec 26, 2016

  1. Preserve RECURSIVE flag of CTE relations when they are merged.

    Queries like the following:
    Tag.all.merge(Tag.with.recursive(recursive: Tag.where(tag: 'tag')))
    Tag.with.recursive(recursive: Tag.where(tag: 'tag')).merge(Tag.all)
    
    would both be expected to produce a query like:
    WITH RECURSIVE "recursive"
       AS ( SELECT "tags".*
              FROM "tags"
             WHERE "tags"."tag" = 'tag')
    SELECT "tags".*
      FROM "tags"
    
    but currently only the second one would. The first would lose the recursive flag
    during merge and result in:
    WITH "recursive"
       AS ( SELECT "tags".*
              FROM "tags"
             WHERE "tags"."tag" = 'tag')
    SELECT "tags".*
      FROM "tags"
    
    Adding :recursive to ActiveRecord::Relation::Merger#normal_values
    and a #recursive! method to ActiveRecord::QueryMethods the expected behavior
    regardless of the direction of the merge.
    jsnelling committed Dec 26, 2016
    Configuration menu
    Copy the full SHA
    fca0acd View commit details
    Browse the repository at this point in the history