- Issue created by @beerendlauwers
I have a paragraph type content_gallery
that is used twice in my node 1002
. However, the report says there are 8 occurrences.
Executing the query manually for that paragraph type and parent ID, I get this:
+-------+-----------------+--------+-----------+-------------+----------------------+-------------+-----------+
| id | type | status | parent_id | parent_type | parent_field_name | entity_type | is_active |
+-------+-----------------+--------+-----------+-------------+----------------------+-------------+-----------+
| 19193 | content_gallery | 1 | 1002 | node | field_content_blocks | home_page | home_page |
| 19193 | content_gallery | 1 | 1002 | node | field_content_blocks | home_page | home_page |
| 19193 | content_gallery | 1 | 1002 | node | field_content_blocks | home_page | home_page |
| 19193 | content_gallery | 1 | 1002 | node | field_content_blocks | home_page | home_page |
| 20935 | content_gallery | 1 | 1002 | node | field_content_blocks | home_page | home_page |
| 20935 | content_gallery | 1 | 1002 | node | field_content_blocks | home_page | home_page |
| 20935 | content_gallery | 1 | 1002 | node | field_content_blocks | home_page | home_page |
| 20935 | content_gallery | 1 | 1002 | node | field_content_blocks | home_page | home_page |
+-------+-----------------+--------+-----------+-------------+----------------------+-------------+-----------+
8 rows in set (0.003 sec)
This looks like a prime candidate for using DISTINCT
, which solves the problem:
+-------+-----------------+--------+-----------+-------------+----------------------+-------------+-----------+
| id | type | status | parent_id | parent_type | parent_field_name | entity_type | is_active |
+-------+-----------------+--------+-----------+-------------+----------------------+-------------+-----------+
| 19193 | content_gallery | 1 | 1002 | node | field_content_blocks | home_page | home_page |
| 20935 | content_gallery | 1 | 1002 | node | field_content_blocks | home_page | home_page |
+-------+-----------------+--------+-----------+-------------+----------------------+-------------+-----------+
2 rows in set (0.003 sec)
Add DISTINCT
to the built query in getSqlBundle
.
Active
1.0
Code