You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
By removing the .includes(:translations).references(:translations) from the spree_base_scopes method in SpreeGlobalize::Translatable the query succeeds. You can see this in action on our fork. https://github.com/ECHOInternational/spree_globalize
The generated SQL becomes much simpler and works properly:
SELECT DISTINCT spree_products.*, MIN(spree_products_taxons.position) AS min_position
FROM"spree_products"INNER JOIN"spree_products_stores"ON"spree_products"."id"="spree_products_stores"."product_id"INNER JOIN"spree_variants"ON"spree_variants"."deleted_at" IS NULLAND"spree_variants"."product_id"="spree_products"."id"INNER JOIN"spree_prices"ON"spree_prices"."deleted_at" IS NULLAND"spree_prices"."variant_id"="spree_variants"."id"INNER JOIN"spree_products_taxons"ON"spree_products_taxons"."product_id"="spree_products"."id"WHERE"spree_products"."deleted_at" IS NULLAND"spree_products_stores"."store_id"=4AND"spree_prices"."currency"='USD'AND"spree_prices"."amount"IS NOT NULLAND"spree_products_taxons"."taxon_id"=55AND ("spree_products".deleted_at IS NULLor"spree_products".deleted_at >='2021-08-25 19:02:05.891093') AND ("spree_products".discontinue_on IS NULLor"spree_products".discontinue_on >='2021-08-25 19:02:05.891439') AND ("spree_products".available_on <='2021-08-25 19:02:05.891420') AND"spree_prices"."currency"='USD'AND"spree_prices"."amount"IS NOT NULLAND"spree_products_taxons"."taxon_id"=55GROUP BY"spree_products"."id"ORDER BY"min_position"ASCLIMIT12
OFFSET 0
Compare this to the generated query below that is currently created and fails:
Steps to Replicate:
Expected Behaviour
The page will load with a list of products that belong to that taxon
Actual Behaviour
PG::GroupingError
PG::GroupingError: ERROR: column "spree_product_translations.id" must appear in the GROUP BY clause or be used in an aggregate function
Environment
Diagnosis
The Spree_Globalize gem preloads translations by adding to the
spree_base_scope
method.The addition of this preloaded scope causes the generated SQL query to be invalid. The SQL query that is failing is listed below.
Workaround (Not necessarily a fix)
By removing the
.includes(:translations).references(:translations)
from thespree_base_scopes
method inSpreeGlobalize::Translatable
the query succeeds. You can see this in action on our fork. https://github.com/ECHOInternational/spree_globalizeThe generated SQL becomes much simpler and works properly:
Compare this to the generated query below that is currently created and fails:
SQL Query that fails
Stack Trace
The text was updated successfully, but these errors were encountered: