vierge-noire / cakephp-fixture-factories

CakePHP Fixture Factories
https://vierge-noire.github.io/
MIT License
83 stars 21 forks source link

Error: Column "id" is an identity column defined as GENERATED ALWAYS #199

Closed ishanvyas22 closed 1 year ago

ishanvyas22 commented 1 year ago

Currently postgres jobs are failing on PHP 8.0 & 8.2 with below error:

...

171) CakephpFixtureFactories\Test\TestCase\Scenario\FixtureScenarioTest::testLoadScenario with data set #2 ('TenAustralianAuthors', 10)
CakephpFixtureFactories\Error\FixtureScenarioException: Error in Factory CakephpFixtureFactories\Test\Factory\AuthorFactory.
 Message: SQLSTATE[428C9]: <<Unknown error>>: 7 ERROR:  cannot insert a non-DEFAULT value into column "id"
DETAIL:  Column "id" is an identity column defined as GENERATED ALWAYS.
HINT:  Use OVERRIDING SYSTEM VALUE to override. 

...

This is due to changes of phinx package in version 0.13.0 (PR: https://github.com/cakephp/phinx/pull/2085).

pabloelcolombiano commented 1 year ago

It is impossible with the actual phinx version to overwrite ID values. See the issue here: https://github.com/cakephp/phinx/issues/2193

A solution would be to add a ->disablePrimaryKeyOffset() to by-pass the random setting of the primary key and let the SQL engine manage the assignment.