Skip to content

feat: add support for the UUID data type#387

Merged
olavloite merged 1 commit intomainfrom
uuid-type
Feb 11, 2026
Merged

feat: add support for the UUID data type#387
olavloite merged 1 commit intomainfrom
uuid-type

Conversation

@olavloite
Copy link
Collaborator

Adds support for the new Spanner data type UUID.

@olavloite olavloite requested a review from a team February 9, 2026 13:01
@product-auto-label product-auto-label bot added the api: spanner Issues related to the googleapis/ruby-spanner-activerecord API. label Feb 9, 2026
@gemini-code-assist
Copy link

Summary of Changes

Hello @olavloite, 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 integrates the UUID data type into the Spanner adapter, allowing applications to leverage universally unique identifiers within their Spanner databases. It provides the necessary framework for defining UUID columns, mapping them to Ruby types, and performing CRUD operations, thereby expanding the data modeling capabilities of the adapter.

Highlights

  • UUID Data Type Support: Introduced comprehensive support for the Spanner UUID data type, including single UUID columns and ARRAY<UUID> columns.
  • Schema and Type Mapping Updates: Modified schema definitions, type mapping configurations, and the Spanner ActiveRecord converter to recognize and handle the new UUID type.
  • Extensive Test Coverage: Added new test cases and updated existing ones to ensure correct creation, updating, and retrieval of UUID and ARRAY<UUID> values across various scenarios, including mutations, DML, and migrations.
Changelog
  • acceptance/cases/tasks/database_tasks_test.rb
    • Added col_uuid UUID and col_array_uuid ARRAY<UUID> to expected schema SQL for both emulator and production environments.
  • acceptance/cases/type/all_types_test.rb
    • Updated create_test_record to include col_uuid and col_array_uuid in test data.
    • Added assertions for col_uuid and col_array_uuid in test_create_record to verify correct storage and retrieval.
    • Modified test_update_record to include col_uuid and col_array_uuid in update operations and added corresponding assertions.
    • Extended test_create_empty_arrays to handle empty col_array_uuid.
  • acceptance/schema/schema.rb
    • Added t.column :col_uuid, :uuid and t.column :col_array_uuid, :uuid, array: true to the test schema definition.
  • lib/active_record/connection_adapters/spanner/type_mapping.rb
    • Added uuid: { name: "UUID" } to NATIVE_DATABASE_TYPES to map ActiveRecord's :uuid to Spanner's UUID.
  • lib/active_record/connection_adapters/spanner_adapter.rb
    • Required the new active_record/type/spanner/uuid file.
    • Registered ActiveRecord::Type::Spanner::Uuid for the UUID type in the type map.
    • Registered ARRAY<UUID> with Type::Spanner::Array for array handling.
  • lib/active_record/type/spanner/spanner_active_record_converter.rb
    • Added conversion logic for ActiveRecord::Type::Spanner::Uuid to :UUID.
  • lib/active_record/type/spanner/uuid.rb
    • Created a new class ActiveRecord::Type::Spanner::Uuid to represent the UUID type.
  • test/activerecord_spanner_mock_server/model_helper.rb
    • Updated register_all_types_columns_result to include mock results for col_uuid and col_array_uuid.
  • test/activerecord_spanner_mock_server/spanner_active_record_with_mock_server_test.rb
    • Added securerandom require for UUID generation.
    • Modified test_create_all_types_using_mutation to include col_uuid and col_array_uuid in mutations and assertions.
    • Updated test_create_all_types_using_dml to reflect UUID columns in DML statements and parameter types.
    • Added a new test test_get_uuid to verify retrieval of UUID and ARRAY<UUID> values.
  • test/migrations_with_mock_server/db/migrate/03_create_all_native_migration_types.rb
    • Added t.column :col_uuid, :uuid and t.column :col_array_uuid, :uuid, array: true to the migration file.
  • test/migrations_with_mock_server/db/migrate/10_create_parent_and_child_with_uuid_pk.rb
    • Changed primary key type for parentid from STRING(36) to UUID in parent_with_uuid_pk and child_with_uuid_pk tables.
  • test/migrations_with_mock_server/migrations_with_mock_server_test.rb
    • Updated expected DDL statements in test_create_all_native_migration_types to include UUID and ARRAY<UUID> columns.
    • Adjusted expected DDL statements in test_interleaved_table_with_uuid_pk to reflect UUID as the primary key type.
Activity
  • The author olavloite initiated this pull request to introduce support for the UUID data type in the Spanner adapter.
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 adds support for the UUID data type in Spanner, which is a valuable enhancement. The changes are comprehensive, touching upon type mapping, schema definitions, and including extensive tests for both DML and mutations. The implementation is clean and aligns well with the existing codebase patterns. I've identified one minor issue in a test file involving a duplicated assertion, which I've commented on. Overall, this is a solid contribution.

Adds support for the new Spanner data type `UUID`.
@olavloite olavloite merged commit b1aecb1 into main Feb 11, 2026
52 checks passed
@olavloite olavloite deleted the uuid-type branch February 11, 2026 12:40
cbarton pushed a commit to cbarton/ruby-spanner-activerecord that referenced this pull request Mar 20, 2026
Adds support for the new Spanner data type `UUID`.
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/ruby-spanner-activerecord API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants