Closed MacKP closed 1 year ago
@Ainschy can you check this?
Yes, it is a bug. I am working on fixing it.
related with https://github.com/MetaModels/core/issues/880
The issue also exits in MetaModels 2.3.
Given SQL
SELECT * FROM mm_region
WHERE IF (
{{param::get?name=act}} = 'edit',
(
pid = (
SELECT unterkunft_region_land
FROM mm_unterkunft
WHERE
id=SUBSTRING_INDEX( {{param::get?name=id}} ,'::',-1)
)
),
(
pid != ''
)
)
Result after CustomSQL
breaks it:
SELECT * FROM mm_region
WHERE IF (
NULL = 'edit',
(
pid = (
SELECT unterkunft_region_land
FROM mm_unterkunft
WHERE
id=SUBSTRING_INDEX(NULL{{,'::',-1)
)
),
(
pid != ''
)
)
}}
When no default value is defined, the answer is NULL
{{param::get?name=category&default=defaultcat}}
When no default value is defined, the answer is NULL
{{param::get?name=category&default=defaultcat}}
@baumannsven implemented this once - unfortunately I can no longer say exactly why... before it was an empty string
This was to allow for null
. If you want an empty string, you should use an empty default AFAIR.
After discussion with @dmolineus:
Given SQL
SELECT * FROM mm_region
WHERE IF (
{{param::get?name=act}} = 'edit',
(
pid = (
SELECT unterkunft_region_land
FROM mm_unterkunft
WHERE
id=SUBSTRING_INDEX( {{param::get?name=id}} ,'::',-1)
)
),
(
pid != ''
)
)
The expected Result is (green=expected;red=incorrectly generated)
SELECT * FROM mm_region
WHERE IF (
NULL = 'edit',
(
pid = (
SELECT unterkunft_region_land
FROM mm_unterkunft
WHERE
+ id=SUBSTRING_INDEX(NULL,'::',-1)
- id=SUBSTRING_INDEX(NULL{{,'::',-1)
)
),
(
pid != ''
)
)
-}}
Fixed with https://github.com/MetaModels/core/pull/1496
Checklist before I submit this issue report
I confirm that:
My environment is:
(Please fill in the actual values from your environment - check Contao Manager or use
composer show
)Issue description
I have an SQL with:
WHERE language = {{iflng::de}}1{{iflng::en}}3{{iflng::nl}}2{{iflng::es}}4{{iflng::el}}5{{iflng}}
In MM Version 2.2.7 i get this query:WHERE language = 13245iflng
I have tested this with MM Version 2.2.6 and there is no bug in that way. I think the patch https://github.com/MetaModels/core/commit/121daee1cd975ad826c23eb655df97ff5d7fe07c is not realy a good sollution ;-)
Kind regards