googleapis / ruby-spanner-activerecord

Spanner<->ActiveRecord adapter for Ruby
MIT License
87 stars 30 forks source link

fix: failed to convert active model type to spanner type under certain condition #299

Closed ruzia closed 7 months ago

ruzia commented 8 months ago

In some cases, such as time related columns, a DelegateClass like ActiveRecord::AttributeMethods::TimeZoneConversion::TimeZoneConverter is passed to the type.

It cause ArgumentError: Cannot determine type for nil values. exception at here.

conventional-commit-lint-gcf[bot] commented 8 months ago

🤖 I detect that the PR title and the commit message differ and there's only one commit. To use the PR title for the commit history, you can use Github's automerge feature with squashing, or use automerge label. Good luck human!

-- conventional-commit-lint bot https://conventionalcommits.org/

olavloite commented 8 months ago

@ruzia Would you mind adding a test for this, or otherwise add a code sample to this PR that shows how this would normally be used, then I can add a test case for it.

ruzia commented 8 months ago

@olavloite

I have created a simple rails application that causes problems. https://github.com/ruzia/type_conversion_test When I try to sign up a user using the devise gem, I get "ArgumentError: Cannot determine type for nil values." error.

  1. rewrite config/database.yml to match your environment
  2. Prepare cloud_spanner.json and rails db:migrate
  3. Start rails and open http://0.0.0.0:3000/users/sign_up
  4. You will get an error when you try to register a user.

I am connecting to Cloud Spanner on GCP, not an emulator.