spree icon indicating copy to clipboard operation
spree copied to clipboard

fix property filters to work with Postgres

Open mrbrdo opened this issue 3 years ago • 6 comments

This should be DB-agnostic and also works with Postgres now.

mrbrdo avatar May 26 '22 23:05 mrbrdo

Changes preview:

Legend:

👀 Review pull request on Viezly

viezly[bot] avatar May 26 '22 23:05 viezly[bot]

@rafalcymerys

mrbrdo avatar Oct 25 '22 21:10 mrbrdo

Hi @mrbrdo - what was the problem with postgres here? I have my intuition, but would like to confirm if I'm reading it correctly ;)

rafalcymerys avatar Oct 28 '22 13:10 rafalcymerys

@rafalcymerys I think the problem was that the scope coming in has an order, and postgres needs you to order first by the columns you are selecting DISTINCT. therefore the query failed as the ORDER BY is by something other than what we are pluck-ing. In any case it surely had to do with the ORDER BY part which Postgres didn't like in some combination of incoming scope. Either due to distinct query or group by or something like that.

mrbrdo avatar Oct 28 '22 13:10 mrbrdo

That makes sense. Was that an issue coming out of your customization (where the scope coming in had the order set) or an issue in core spree?

rafalcymerys avatar Nov 02 '22 22:11 rafalcymerys

@rafalcymerys hard to remember after 6 months. I don't think I did any changes to properties, so I'd guess it was related to spree core. I have some vague recollection that in one case the scope coming in depended on selected filter/sort value, and only under a certain condition would it cause issues, I think it was when doing a search (Ransack). If I was providing said scope I would fix that code rather than spree core which I try to avoid when possible.

mrbrdo avatar Nov 03 '22 11:11 mrbrdo