craftcms / cms

Build bespoke content experiences with Craft.
https://craftcms.com
Other
3.23k stars 630 forks source link

normalize select for decimal casting #15274

Closed i-just closed 3 months ago

i-just commented 3 months ago

Description

Following changes from #15222, a query that selects a single cast statement for a number field causes an error. That’s because yiisoft/yii2/db/Query->normalizeSelect() looks for commas to split the select string into an array of values. Now that we’re casting decimals to decimal(65,16) (for MySQL) and not just decimal, the comma inside there was being matched by normalizeSelect(), causing the raw query to look like:

SELECT DISTINCT CAST((`elements_sites`.`content`->>'$.\"<uid>\"') AS DECIMAL(65, `16))`

instead of

SELECT DISTINCT CAST((`elements_sites`.`content`->>'$.\"<uid>\"') AS DECIMAL(65, 16))

Fixed by excluding commas preceded by an opening parenthesis and two digits.

Related issues

15271