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

[Spree 2.1] Adapt to Rails 4 - subquery has too many columns #3708

Closed
luisramos0 opened this issue Apr 7, 2019 · 1 comment · Fixed by #4802
Closed

[Spree 2.1] Adapt to Rails 4 - subquery has too many columns #3708

luisramos0 opened this issue Apr 7, 2019 · 1 comment · Fixed by #4802
Assignees

Comments

@luisramos0
Copy link
Contributor

Looks like that in rails 4 we need to be a it more specific when using IN operator otherwise we get this type of error:

71) Spree::Product scopes access roles shows only products for given user
      Failure/Error: product.count.should == 1
      
      ActiveRecord::StatementInvalid:
        PG::SyntaxError: ERROR:  subquery has too many columns
        LINE 1: ...e_products"."deleted_at" IS NULL AND (supplier_id IN (SELECT...
                                                                     ^
        : SELECT COUNT(*) FROM "spree_products"  WHERE "spree_products"."deleted_at" IS NULL AND (supplier_id IN (SELECT "enterprises".* FROM "enterprises" INNER JOIN "enterprise_roles" ON "enterprises"."id" = "enterprise_roles"."enterprise_id" WHERE "enterprise_roles"."user_id" = $1))
      # ./spec/models/spree/product_spec.rb:326:in `block (4 levels) in <module:Spree>'
      # ------------------
      # --- Caused by: ---
      # PG::SyntaxError:
      #   ERROR:  subquery has too many columns
      #   LINE 1: ...e_products"."deleted_at" IS NULL AND (supplier_id IN (SELECT...
      #                                                                ^
      #   ./spec/models/spree/product_spec.rb:326:in `block (4 levels) in <module:Spree>'

In this case, we can have
supplier_id IN (SELECT "enterprises".*
we need to have
supplier_id IN (SELECT "enterprises"."id"

I couldnt find reference to this here:
https://edgeguides.rubyonrails.org/upgrading_ruby_on_rails.html#upgrading-from-rails-3-2-to-rails-4-0

@sigmundpetersen
Copy link
Contributor

Hey Matt, are you planning to continue on this or should we move it to backlog?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment