spree_favorite_products icon indicating copy to clipboard operation
spree_favorite_products copied to clipboard

[MySQL GROUP BY STRICT RULE] Fails to load Admin Favorites Page

Open pikender opened this issue 8 years ago • 0 comments

When Visiting Products -> Favorite Products /admin/favorite_products, page shows below error

**Note: ** Error is due to MYSQL GROUP BY STRICT RULE ENABLED BY DEFAULT or check this

ActiveRecord::StatementInvalid - Mysql2::Error: Expression #1 of ORDER BY contains aggregate function and applies to the result of a non-aggregated query: SELECT  DISTINCT `spree_products`.* FROM `spree_products` INNER JOIN `spree_favorites` ON `spree_favorites`.`product_id` = `spree_products`.`id` WHERE `spree_products`.`deleted_at` IS NULL  ORDER BY count(spree_favorites.user_id) desc LIMIT 25 OFFSET 0:
  activerecord (4.2.7.1) lib/active_record/connection_adapters/abstract_adapter.rb:473:in `translate_exception_class'
  activerecord (4.2.7.1) lib/active_record/connection_adapters/abstract_adapter.rb:486:in `rescue in log'
  activerecord (4.2.7.1) lib/active_record/connection_adapters/abstract_adapter.rb:484:in `log'
  activerecord (4.2.7.1) lib/active_record/connection_adapters/abstract_mysql_adapter.rb:309:in `execute'
  activerecord (4.2.7.1) lib/active_record/connection_adapters/mysql2_adapter.rb:231:in `execute'
  activerecord (4.2.7.1) lib/active_record/connection_adapters/mysql2_adapter.rb:235:in `exec_query'
  activerecord (4.2.7.1) lib/active_record/connection_adapters/abstract/database_statements.rb:356:in `select'
  activerecord (4.2.7.1) lib/active_record/connection_adapters/abstract/database_statements.rb:32:in `select_all'
  activerecord (4.2.7.1) lib/active_record/connection_adapters/abstract/query_cache.rb:68:in `block in select_all'
  activerecord (4.2.7.1) lib/active_record/connection_adapters/abstract/query_cache.rb:83:in `cache_sql'
  activerecord (4.2.7.1) lib/active_record/connection_adapters/abstract/query_cache.rb:68:in `select_all'
  activerecord (4.2.7.1) lib/active_record/querying.rb:39:in `find_by_sql'
  activerecord (4.2.7.1) lib/active_record/relation.rb:639:in `exec_queries'
  activerecord (4.2.7.1) lib/active_record/relation.rb:515:in `load'
  activerecord (4.2.7.1) lib/active_record/relation.rb:243:in `to_a'
  activerecord (4.2.7.1) lib/active_record/relation/delegation.rb:46:in `each'
  /Users/pikender/spree/marketing/products/spree_favorite_products/app/views/spree/admin/favorite_products/index.html.erb:26:in `_159f37bc5a59b9d09b8a7c99092e39eb'

pikender avatar Feb 20 '17 13:02 pikender