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

ActiveRecord::StatementInvalid in Spree::Admin::Products#index after installation #52

Open
exocode opened this issue Oct 14, 2018 · 4 comments

Comments

@exocode
Copy link

exocode commented Oct 14, 2018

Hi there, I try to get an fresh installed Spree Shop running with "spree_globalize".

• When I am logged in as admin
• and I click on products
• Then I see this error:

ActiveRecord::StatementInvalid in Spree::Admin::Products#index

Showing /Users/janjezek/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/spree_backend-3.6.4/app/views/spree/admin/products/index.html.erb where line #68 raised:

Mysql2::Error: Expression #1 of ORDER BY clause is not in SELECT list, references column 'demo520-spree_development.spree_products.name' which is not in SELECT list; this is incompatible with DISTINCT: SELECT  DISTINCT `spree_products`.`id`, `spree_products`.`available_on`, `spree_products`.`discontinue_on`, `spree_products`.`deleted_at`, `spree_products`.`tax_category_id`, `spree_products`.`shipping_category_id`, `spree_products`.`created_at`, `spree_products`.`updated_at`, `spree_products`.`promotionable` FROM `spree_products` WHERE `spree_products`.`deleted_at` IS NULL AND (`spree_products`.discontinue_on IS NULL or `spree_products`.discontinue_on >= '2018-10-14 19:08:22.259918') ORDER BY `spree_products`.`name` ASC LIMIT 25 OFFSET 0

129  | def query(sql, options = {})       
130     Thread.handle_interrupt(::Mysql2::Util::TIMEOUT_ERROR_CLASS => :never) do
131        _query(sql, @query_options.merge(options))
132     end
133  end

Full Stacktrace here: http://pasted.co/2c4be2fa

What I've done

  • I installed Spree
  • i18n
  • Globalize (as well as activemodel-serializers-xml and globalize to resolve the dependenies)
ruby '2.5.1'
gem 'rails', '~> 5.2.0'

gem 'spree', '~> 3.6.4'
gem 'spree_auth_devise', '~> 3.3'
gem 'spree_gateway', '~> 3.3'

gem 'spree_i18n', github: 'spree-contrib/spree_i18n'
gem 'globalize', git: 'https://github.com/globalize/globalize'
gem 'activemodel-serializers-xml'
gem 'spree_globalize', github: 'spree-contrib/spree_globalize'

I uploaded a git Repo to jumpstart:
https://github.com/exocode/demo520-spree364

git clone [email protected]:exocode/demo520-spree364.git
cd demo520-spree364
bundle install
nano database.yml to your needs
rake db:snapshot:restore to restore same state where it fails

I hope someone can help me.

@khataev
Copy link

khataev commented Nov 26, 2018

I had the same issue. What's interesting - problem appears only on postgres database with i18n/globalize gems. When I create local demo on default sqlite3 - everything is ok.

@AhmedAliIbrahim
Copy link

Did you find any solution or workaround ?

@khataev
Copy link

khataev commented Feb 3, 2019

No, I did not

@mrbrdo
Copy link

mrbrdo commented Mar 7, 2022

It has to do with Postgres, which is stricter on proper SQL, I have the same issue(s). Looking for a solution as well, because it comes up through multiple paths (different methods of friendly_id and the globalize version of it).
It seems the main culprit is the *-globalize gems.
I also get ActiveRecord::StatementInvalid: PG::GroupingError: ERROR: column "spree_product_translations.id" must appear in the GROUP BY clause or be used in an aggregate function for a different query.

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

No branches or pull requests

4 participants