mollie / spree-mollie-gateway

Mollie payments for Spree Commerce.
https://www.mollie.com
16 stars 23 forks source link

Bug in orders index when using spree_globalize #95

Open Kulgar opened 3 years ago

Kulgar commented 3 years ago

I get this error when using spree mollie gateway with spree globalize : (Strange fact: I get the error once the app is deployed, not in my dev environment...)

ActionView::Template::Error (PG::InvalidColumnReference: ERROR:  for SELECT DISTINCT, ORDER BY expressions must appear in select list
LINE 1: ...store_translations"."locale" IN ($1, $2) ORDER BY spree_stor...
                                                             ^
: SELECT DISTINCT spree_store_translations.name, "spree_stores"."id" FROM "spree_stores" INNER JOIN "spree_store_translations" ON "spree_store_translations"."spree_store_id" = "spree_stores"."id" WHERE "spree_store_translations"."locale" IN ($1, $2) ORDER BY spree_stores.name):

<div class="col-xs-12 col-md-4">
  <div class="form-group">
    <%= label_tag :q_store_id_in, Spree.t(:store) %>
    <%= f.select :store_id_in, Spree::Store.order("#{Spree::Store.table_name}.name").pluck(:name, :id), {include_blank: true}, class: 'select2' %>
  </div>
</div>

I actually don't understand why you put "#{Spree::Store.table_name}" in the above line. A simple Spree::Store.order("name").pluck(:name, :id), works just fine and doesn't raise the above bug.

And, indeed, this is the code used in official backend repository: https://github.com/spree/spree/blob/master/backend/app/views/spree/admin/orders/index.html.erb#L134

Could that be fixed? Thanks! (I'll open a little PR)

Could I also open another PR that gets all updates from official backend files to this gem?