-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24 from roxblnfk/hotfix/23
Embedded entity's fields conflict with the parent ones even using columnPrefix
- Loading branch information
Showing
9 changed files
with
133 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
src/Exception/FieldException/EmbeddedPrimaryKeyException.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Cycle\Schema\Exception\FieldException; | ||
|
||
use Cycle\Schema\Definition\Entity; | ||
use Cycle\Schema\Exception\FieldException; | ||
use Yiisoft\FriendlyException\FriendlyExceptionInterface; | ||
|
||
final class EmbeddedPrimaryKeyException extends FieldException implements FriendlyExceptionInterface | ||
{ | ||
|
||
public function __construct(Entity $embed, string $fieldName) | ||
{ | ||
parent::__construct("Entity `{$embed->getRole()}` has conflicted field `{$fieldName}`."); | ||
} | ||
|
||
public function getName(): string | ||
{ | ||
return 'Embedded entity primary key collision'; | ||
} | ||
|
||
public function getSolution(): ?string | ||
{ | ||
return "The primary key of the composite entity must be projected onto the embedded entity.\n" | ||
. "However, the embedded entity already has a field with the same name.\n\n" | ||
. "Possible solutions:\n" | ||
. "- If the conflicting field applies only to an embedded entity, then rename it.\n" | ||
. '- If you want to receive the primary key value of a composite entity in this field,' | ||
. ' then remove its definition from the column list in the schema.'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
/** | ||
* Spiral Framework. | ||
* | ||
* @license MIT | ||
* @author Anton Titov (Wolfy-J) | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Cycle\Schema\Tests\Driver\MySQL; | ||
|
||
class EmbeddedTest extends \Cycle\Schema\Tests\Relation\EmbeddedTest | ||
{ | ||
public const DRIVER = 'mysql'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
/** | ||
* Spiral Framework. | ||
* | ||
* @license MIT | ||
* @author Anton Titov (Wolfy-J) | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Cycle\Schema\Tests\Driver\Postgres; | ||
|
||
class EmbeddedTest extends \Cycle\Schema\Tests\Relation\EmbeddedTest | ||
{ | ||
public const DRIVER = 'postgres'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Cycle\Schema\Tests\Driver\SQLServer; | ||
|
||
class EmbeddedTest extends \Cycle\Schema\Tests\Relation\EmbeddedTest | ||
{ | ||
public const DRIVER = 'sqlserver'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
/** | ||
* Spiral Framework. | ||
* | ||
* @license MIT | ||
* @author Anton Titov (Wolfy-J) | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Cycle\Schema\Tests\Driver\SQLite; | ||
|
||
class EmbeddedTest extends \Cycle\Schema\Tests\Relation\EmbeddedTest | ||
{ | ||
public const DRIVER = 'sqlite'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters