Skip to content

Commit

Permalink
IBX-6824: Fixed inheritance column reported as invalid
Browse files Browse the repository at this point in the history
  • Loading branch information
Steveb-p authored Oct 18, 2023
1 parent 64b6488 commit a9d2b50
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/lib/Gateway/ExpressionVisitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public function walkComparison(Comparison $comparison)
return $this->handleTranslation($comparison);
}

if (!$this->schemaMetadata->hasColumn($column)) {
if (!$this->schemaMetadata->hasColumn($column) && !$this->schemaMetadata->isInheritedColumn($column)) {
throw new RuntimeMappingException(sprintf(
'%s table metadata does not contain %s column.',
$this->schemaMetadata->getTableName(),
Expand Down
27 changes: 27 additions & 0 deletions tests/bundle/Gateway/ExpressionVisitorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,33 @@ public function testFieldFromInheritedRelationship(): void
);
}

public function testFieldFromSubclass(): void
{
$this->schemaMetadata
->expects(self::exactly(2))
->method('isInheritedColumn')
->with('inherited_field')
->willReturn(true);

$inheritanceMetadata = $this->createMock(DoctrineSchemaMetadataInterface::class);
$this->schemaMetadata
->expects(self::once())
->method('getInheritanceMetadataWithColumn')
->with('inherited_field')
->willReturn($inheritanceMetadata);

$inheritanceMetadata
->expects(self::once())
->method('getTableName')
->willReturn('inheritance_table');

$result = $this->expressionVisitor->dispatch(new Comparison('inherited_field', '=', 'value'));
self::assertSame(
'inheritance_table.inherited_field = :inherited_field_0',
$result,
);
}

private function createRelationshipSchemaMetadata(): DoctrineSchemaMetadataInterface
{
$relationshipMetadata = $this->createMock(DoctrineSchemaMetadataInterface::class);
Expand Down

0 comments on commit a9d2b50

Please sign in to comment.