@@ -378,7 +378,7 @@ private static function getToOneQuery(string $jsonKey, string $parentTable, stri
378
378
* INNER JOIN (
379
379
* SELECT
380
380
* c.playlist_id,
381
- * CAST(GROUP_CONCAT(c.changed SEPARATOR "") > 0 AS UNSIGNED) changed,
381
+ * CAST(GROUP_CONCAT(DISTINCT c.changed SEPARATOR "") > 0 AS UNSIGNED) changed,
382
382
* SHA1(GROUP_CONCAT(c.id, c.version, c.relations_checksum)) checksum
383
383
* FROM
384
384
* playlist_slide c
@@ -392,10 +392,11 @@ private static function getToOneQuery(string $jsonKey, string $parentTable, stri
392
392
* Explanation:
393
393
* Because this is a "to many" relation we need to GROUP_CONCAT values from the child relations. This is done in a temporary table
394
394
* with GROUP BY parent id in the child table. This gives us just one child row for each parent row with a checksum from the relevant
395
- * fields across all child rows.
395
+ * fields across all child rows. We use a DISTINCT clause in GROUP_CONCAT to limit the length of the resulting value and avoid
396
+ * illegal integer values.
396
397
*
397
398
* This temp table is then joined to the parent table to allow us to SET the p.changed and p.relations_checksum values on the parent.
398
- * - Because GROUP_CONCAT will give us all child rows "changed" as one, e.g. "00010001" we need "> 0" to ecaluate to true/false
399
+ * - Because GROUP_CONCAT will give us all child rows "changed" as one, e.g. "00010001" we need "> 0" to evaluate to true/false
399
400
* and then CAST that to "unsigned" to get a TINYINT (bool)
400
401
* WHERE either p.changed or c.changed is true
401
402
* - Because we can't easily get a list of ID's of affected rows as we work up the tree we use the bool "changed" as clause in
@@ -413,7 +414,7 @@ private static function getOneToManyQuery(string $jsonKey, string $parentTable,
413
414
INNER JOIN (
414
415
SELECT
415
416
c.%s,
416
- CAST(GROUP_CONCAT(c.changed SEPARATOR "") > 0 AS UNSIGNED) changed,
417
+ CAST(GROUP_CONCAT(DISTINCT c.changed SEPARATOR "") > 0 AS UNSIGNED) changed,
417
418
SHA1(GROUP_CONCAT(c.id, c.version, c.relations_checksum)) checksum
418
419
FROM
419
420
%s c
@@ -448,7 +449,7 @@ private static function getOneToManyQuery(string $jsonKey, string $parentTable,
448
449
* INNER JOIN (
449
450
* SELECT
450
451
* pivot.slide_id,
451
- * CAST(GROUP_CONCAT(c.changed SEPARATOR "") > 0 AS UNSIGNED) changed,
452
+ * CAST(GROUP_CONCAT(DISTINCT c.changed SEPARATOR "") > 0 AS UNSIGNED) changed,
452
453
* SHA1(GROUP_CONCAT(c.id, c.version, c.relations_checksum)) checksum
453
454
* FROM
454
455
* slide_media pivot
@@ -463,10 +464,11 @@ private static function getOneToManyQuery(string $jsonKey, string $parentTable,
463
464
* Explanation:
464
465
* Because this is a "to many" relation we need to GROUP_CONCAT values from the child relations. This is done in a temporary table
465
466
* with GROUP BY parent id in the child table. This gives us just one child row for each parent row with a checksum from the relevant
466
- * fields across all child rows.
467
+ * fields across all child rows. We use a DISTINCT clause in GROUP_CONCAT to limit the length of the resulting value and avoid
468
+ * illegal integer values.
467
469
*
468
470
* This temp table is then joined to the parent table to allow us to SET the p.changed and p.relations_checksum values on the parent.
469
- * - Because GROUP_CONCAT will give us all child rows "changed" as one, e.g. "00010001" we need "> 0" to ecaluate to true/false
471
+ * - Because GROUP_CONCAT will give us all child rows "changed" as one, e.g. "00010001" we need "> 0" to evaluate to true/false
470
472
* and then CAST that to "unsigned" to get a TINYINT (bool)
471
473
* WHERE either p.changed or c.changed is true
472
474
* - Because we can't easily get a list of ID's of affected rows as we work up the tree we use the bool "changed" as clause in
@@ -485,7 +487,7 @@ private static function getManyToManyQuery(string $jsonKey, string $parentTable,
485
487
INNER JOIN (
486
488
SELECT
487
489
pivot.%s,
488
- CAST(GROUP_CONCAT(c.changed SEPARATOR "") > 0 AS UNSIGNED) changed,
490
+ CAST(GROUP_CONCAT(DISTINCT c.changed SEPARATOR "") > 0 AS UNSIGNED) changed,
489
491
SHA1(GROUP_CONCAT(c.id, c.version, c.relations_checksum)) checksum
490
492
FROM
491
493
%s pivot
0 commit comments