Skip to content

Commit 8d8a40c

Browse files
author
Tom H Anderson
committed
Added distinct values
1 parent 18ac91b commit 8d8a40c

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ which is missing it's foreign key. Nullable relationships are not evaluated.
2020
php index.php orm:data-validation:relationship --object-manager="doctrine.entitymanager.orm_default"
2121
```
2222

23-
This will output TSV with the Count, Child Field, Child Entity, Parent Entity, and the SQL to duplicate the results for all relationships where data is found in the child which references data not found in the parent.
23+
This will output TSV with the Count, Distinct Values, Child Field, Child Entity, Parent Entity, and the SQL to duplicate the results for all relationships where data is found in the child which references data not found in the parent.
2424

2525

2626
Configure Zend Framework 2 Module

src/Controller/ForeignKeyController.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ public function relationshipAction()
3333
$console->write(
3434
'Count'
3535
. "\t"
36+
. 'Distinct Values'
37+
. "\t"
3638
. 'Child Field'
3739
. "\t"
3840
. 'Child Entity'
@@ -52,7 +54,9 @@ public function relationshipAction()
5254
$queryBuilder2 = $objectManager->createQueryBuilder();
5355

5456
$queryBuilder->select(
55-
"count(child) as ct, '"
57+
"count(child) as ct, count(distinct child."
58+
. $mapping['fieldName']
59+
. ") as dst, '"
5660
. $mapping['fieldName']
5761
. "' as childField, '"
5862
. $metadata->getName()
@@ -94,7 +98,10 @@ public function relationshipAction()
9498
$childMapping = $objectManager->getMetadataFactory()
9599
->getMetadataFor($metadata->getName());
96100

97-
$console->write($result['ct']
101+
$console->write(
102+
$result['ct']
103+
. "\t"
104+
. $result['dst']
98105
. "\t"
99106
. $result['childField']
100107
. "\t"

0 commit comments

Comments
 (0)