Skip to content

Conversation

@prathmeshcc
Copy link
Collaborator

This PR addresses the following:

  • Changes the terminology for client default options commented for transaction unit test.
  • Creates a Sample for Snapshot Isolation

@product-auto-label product-auto-label bot added the samples Issues that are directly related to samples. label Jan 21, 2026
@gemini-code-assist
Copy link

Summary of Changes

Hello @prathmeshcc, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the Google Cloud Spanner C++ client library by introducing a practical example for managing transaction isolation levels and improving the clarity of related documentation and test comments. These changes aim to provide developers with better guidance and understanding of how to effectively configure and utilize different isolation levels within their applications.

Highlights

  • New Isolation Level Example: A new C++ sample (samples.cc) has been added to demonstrate how to configure transaction isolation levels, both at the client-level and by overriding them at the transaction-level.
  • Documentation Update: The spanner-main.dox documentation has been updated to include a new page (spanner-isolation-level-example) that describes the support for isolation levels and links to the new sample.
  • Terminology Refinement: Comments in transaction.h and transaction_test.cc have been updated to use more precise terminology regarding transaction isolation levels, specifically clarifying "snapshot transactions" to "repeatable read transactions" and "client default options" to "default options".

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new sample for setting transaction isolation levels in Spanner, along with corresponding documentation updates. It also refines some terminology in comments within the transaction-related tests and headers for better clarity. The changes are well-structured. I've suggested a couple of improvements to the new sample code to demonstrate best practices by using SQL parameters instead of hardcoded values.

Comment on lines +3495 to +3496
auto sql = spanner::SqlStatement(
"SELECT AlbumTitle from Albums WHERE SingerId = 1 and AlbumId = 1");

Choose a reason for hiding this comment

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

medium

For improved security and to prevent SQL injection vulnerabilities, it's a best practice to use query parameters instead of embedding literal values directly into the SQL string. This also improves readability and maintainability.

        auto sql = spanner::SqlStatement(
            "SELECT AlbumTitle from Albums WHERE SingerId = @SingerId and AlbumId = @AlbumId",
            {{"SingerId", spanner::Value(1)}, {"AlbumId", spanner::Value(1)}});

Comment on lines +3504 to +3507
auto update_sql = spanner::SqlStatement(
"UPDATE Albums "
"SET AlbumTitle = 'New Album Title' "
"WHERE SingerId = 1 and AlbumId = 1");

Choose a reason for hiding this comment

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

medium

Similar to the SELECT statement, it's recommended to use parameters for DML statements to prevent SQL injection and improve code clarity.

        auto update_sql = spanner::SqlStatement(
            "UPDATE Albums "
            "SET AlbumTitle = @AlbumTitle "
            "WHERE SingerId = @SingerId and AlbumId = @AlbumId",
            {{"AlbumTitle", spanner::Value("New Album Title")},
             {"SingerId", spanner::Value(1)},
             {"AlbumId", spanner::Value(1)}});

@codecov
Copy link

codecov bot commented Jan 21, 2026

Codecov Report

❌ Patch coverage is 10.34483% with 26 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.95%. Comparing base (3959c49) to head (3b360f6).

Files with missing lines Patch % Lines
google/cloud/spanner/samples/samples.cc 10.34% 26 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #15895      +/-   ##
==========================================
- Coverage   92.95%   92.95%   -0.01%     
==========================================
  Files        2460     2460              
  Lines      228641   228670      +29     
==========================================
+ Hits       212544   212550       +6     
- Misses      16097    16120      +23     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@prathmeshcc prathmeshcc deleted the fix/isolation-level-terminology branch January 22, 2026 03:02
@prathmeshcc prathmeshcc restored the fix/isolation-level-terminology branch January 22, 2026 03:05
@prathmeshcc
Copy link
Collaborator Author

Branch was deleted/recreated; opening a fresh PR for these terminology changes in #15900

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

samples Issues that are directly related to samples.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant