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

feat: foreign key on delete cascade #2340

Merged
merged 17 commits into from
Jul 18, 2023
Merged

Conversation

arpan14
Copy link
Contributor

@arpan14 arpan14 commented Mar 20, 2023

  • Adding integration tests for foreign key on delete cascade feature testing both GoogleSQL + PostGres dialects.
  • Adding documentation samples along with integration tests for the samples.
    • Making a minor enhancement in the samples integration test setup framework to allow accepting a host URL in Spanner options to allow overriding and testing in staging env.

@arpan14 arpan14 added the do not merge Indicates a pull request not ready for merge, due to either quality or timing. label Mar 20, 2023
@arpan14 arpan14 requested review from olavloite and asthamohta March 20, 2023 16:30
@arpan14 arpan14 requested a review from a team as a code owner March 20, 2023 16:30
@snippet-bot
Copy link

snippet-bot bot commented Mar 20, 2023

Here is the summary of changes.

You are about to add 3 region tags.

This comment is generated by snippet-bot.
If you find problems with this result, please file an issue at:
https://github.com/googleapis/repo-automation-bots/issues.
To update this comment, add snippet-bot:force-run label or use the checkbox below:

  • Refresh this comment

@product-auto-label product-auto-label bot added size: l Pull request size is large. api: spanner Issues related to the googleapis/java-spanner API. labels Mar 20, 2023
@arpan14 arpan14 added the owlbot:run Add this label to trigger the Owlbot post processor. label Mar 27, 2023
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Mar 27, 2023
@gcf-owl-bot gcf-owl-bot bot requested a review from a team as a code owner March 27, 2023 10:48
Comment on lines +360 to +364
transaction -> {
transaction.batchUpdate(
ImmutableList.of(
singerInsertStatementWithValues, concertInsertStatementWithValues));
return null;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Tip (no need to change it in this PR unless you want to): You can simplify many of these test transactions further if you just return the value that is returned by the batchUpdate (or any other update statement in the transaction). That again would allow you to define the whole transaction as a lambda like this:

    databaseClient
        .readWriteTransaction()
        .run(
            transaction -> transaction.executeUpdate(singerDeleteStatementWithValues));

databaseAdminClient, instanceId, databaseId));

assertTrue(
"Expected to have created database "

Choose a reason for hiding this comment

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

May be instead of checking the output message we should verify that the table was actually altered by the sample or not ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

  • Yes, for all the tests in the integration test class ITForeignKeyDeleteCascadeTest we validate/assert the foreign key constraint.
  • These tests are for the samples. Samples internally use the code that is already validated through ITForeignKeyDeleteCascadeTest . Hence, we don't need to again make a database call.
  • In Java, asserting output statements is a very standard practice across all existing samples. I agree, its not the best strategy but for cases like this where we have other integration tests doing deep DDL checks, I think keeping the sample tests simple is ok.

@arpan14 arpan14 added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jul 13, 2023
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jul 13, 2023
@arpan14 arpan14 removed the do not merge Indicates a pull request not ready for merge, due to either quality or timing. label Jul 17, 2023
@arpan14 arpan14 added the owlbot:run Add this label to trigger the Owlbot post processor. label Jul 18, 2023
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Jul 18, 2023
@arpan14 arpan14 merged commit f659105 into googleapis:main Jul 18, 2023
@arpan14 arpan14 deleted the fkadc-tests-pr branch July 18, 2023 07:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: spanner Issues related to the googleapis/java-spanner API. size: l Pull request size is large.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants