solidus icon indicating copy to clipboard operation
solidus copied to clipboard

currently_valid scope in Spree::Price

Open m-otiv opened this issue 5 years ago • 2 comments

I'm trying to use solidus with Microsoft SqlServer, please, don't ask me why.

Solidus Version: 2.9.6

Current behavior When i try to open the list of product with some product in it, raise me this error: TinyTds::Error: Incorrect syntax near the keyword 'IS'.: EXEC sp_executesql N'SELECT [spree_prices].* FROM [spree_prices] WHERE [spree_prices].[currency] = @0 AND [spree_prices].[country_iso] IS NULL AND [spree_prices].[variant_id] = @1 ORDER BY country_iso IS NULL, [spree_prices].[updated_at] DESC, [spree_prices].[id] DESC', N'@0 nvarchar(4000), @1 int', @0 = N'EUR', @1 = 1

Screenshots image

Solution I found out that this line use the order instead of where to check if country_iso is null

m-otiv avatar Nov 04 '20 11:11 m-otiv

Can you please add some context to reproduce this issue? When/where does this happen?

kennyadsl avatar Nov 04 '20 11:11 kennyadsl

I know Microsoft SQL Server has some stuff around sorting nulls that might be issue. I doubt the country_iso condition is the issue as that's very standard SQL, but I wouldn't be surprised if ORDER BY country_iso IS NULL were not playing nice with SQL Server, but that might be an ActiveRecord issue more than a Solidus one.

Regardless, more context/info would be helpful.

jarednorman avatar Nov 15 '20 23:11 jarednorman

Hello @m-otiv ! Were you able to resolve this issue with SQL server?

gsmendoza avatar Sep 06 '22 08:09 gsmendoza

I think regardless we can probably close this, because if SQLServer doesn't support this query, the ActiveRecord adapter shouldn't be generating it. What we're doing is (as far as I know) a pretty standard way to work around how nulls aren't consistently sorted across different databases.

jarednorman avatar Sep 06 '22 13:09 jarednorman

I'm going to close this, but we can reopen if there's any movement and we actually want to address it.

jarednorman avatar Sep 06 '22 15:09 jarednorman