Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IBX-1258: Fixed multiple FixtureImporter::import() calls not resetting sequences #245

Merged
merged 3 commits into from
Oct 14, 2021

Conversation

Steveb-p
Copy link
Contributor

@Steveb-p Steveb-p commented Oct 14, 2021

Question Answer
JIRA issue IBX-1258
Type improvement
Target Ibexa version v3.3
BC breaks no

This changes the internal cache for FixtureImporter, and how it is regenerated when new fixtures are imported.

Previously, calling FixtureImporter::import() multiple times (with different Fixtures) was possible, but sequence keys for Fixtures after the first one were not regenerated properly. This results in issues when different tests receive different fixtures, usually concluding in primary key constraint validations.

Checklist:

  • Provided PR description.
  • Tested the solution manually.
  • Provided automated test coverage.
  • Checked that target branch is set correctly (master for features, the oldest supported for bugs).
  • Ran PHP CS Fixer for new PHP code (use $ composer fix-cs).
  • Asked for a review (ping @ezsystems/engineering-team).

$queryTemplate,
$sequenceName,
$this->connection->quoteIdentifier($columnName),
$this->connection->getDatabasePlatform()->getMaxExpression(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extract $this->connection->getDatabasePlatform() to the variable set outside of foreach scope please

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in bfbb062.

Additionally variable name containing tables that were not previously covered by sequence reset value generation is renamed from $diff to $unvisitedTables.

@Steveb-p Steveb-p changed the title RFC: Fixed multiple FixtureImporter::import() calls not resetting sequences IBX-1258: Fixed multiple FixtureImporter::import() calls not resetting sequences Oct 14, 2021
@Steveb-p Steveb-p requested review from a team and alongosz October 14, 2021 14:30
@Steveb-p
Copy link
Contributor Author

@alongosz codebase has been changed to include the fact that some tables might not have an autoincrement column - which in previous code would cause them to be constantly queried.

This causes the FixtureImporter::$resetSequenceStatements property to change it's declaration to array<string, string|null>, where null value indicates a table without autoincrement.

@sonarcloud
Copy link

sonarcloud bot commented Oct 14, 2021

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@Steveb-p Steveb-p merged commit d7f7460 into 1.3 Oct 14, 2021
@Steveb-p Steveb-p deleted the rfc/fix-multiple-fixture-imports branch October 14, 2021 21:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
3 participants