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

fix: allow functions to be default values #252

Merged
merged 8 commits into from
Jun 1, 2023

Conversation

nownabe
Copy link
Contributor

@nownabe nownabe commented May 16, 2023

Fix #247

@nownabe nownabe requested review from a team and olavloite as code owners May 16, 2023 02:20
@product-auto-label product-auto-label bot added the api: spanner Issues related to the googleapis/ruby-spanner-activerecord API. label May 16, 2023
@nownabe
Copy link
Contributor Author

nownabe commented May 16, 2023

On GitHub Actions, the right parenthesis of CURRENT_TIMESTAMP() dissapears... 🤔

# GitHub Action
#<Google::Cloud::Spanner::Data ((COLUMN_NAME)"col_timestamp", (SPANNER_TYPE)"TIMESTAMP", (IS_NULLABLE)"YES", (GENERATION_EXPRESSION)nil, (COLUMN_DEFAULT)"CURRENT_TIMESTAMP(", (ORDINAL_POSITION)2)>

# Local
#<Google::Cloud::Spanner::Data ((COLUMN_NAME)"col_timestamp", (SPANNER_TYPE)"TIMESTAMP", (IS_NULLABLE)"YES", (GENERATION_EXPRESSION)nil, (COLUMN_DEFAULT)"CURRENT_TIMESTAMP()", (ORDINAL_POSITION)2)>

Because newer Spanner emulators have a bug aroud information schema.
They cannot return correct values for COLUMN_DEFAULT.

spanner> SELECT COLUMN_NAME, COLUMN_DEFAULT FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME="dynamic_items";
+---------------+--------------------+
| COLUMN_NAME   | COLUMN_DEFAULT     |
+---------------+--------------------+
| id            | NULL               |
| col_timestamp | CURRENT_TIMESTAMP( |
+---------------+--------------------+
2 rows in set (2.079298ms)
@nownabe
Copy link
Contributor Author

nownabe commented May 16, 2023

On GitHub Actions, the right parenthesis of CURRENT_TIMESTAMP() dissapears...

It was a bug of emulator v1.5.1 and newer.

@nownabe
Copy link
Contributor Author

nownabe commented May 17, 2023

@olavloite
Copy link
Collaborator

@nownabe Thanks for this change. LGTM. I've reverted the tests to using the latest version of the emulator, as it appears that the bug that you discovered has been fixed.

@olavloite
Copy link
Collaborator

The current build error appears to be caused by ActiveRecord 7.0.5, which contains a change in index_exists?: https://github.com/rails/rails/blob/v7.0.5/activerecord/CHANGELOG.md

@olavloite olavloite merged commit f651bbf into googleapis:main Jun 1, 2023
28 checks passed
@nownabe nownabe deleted the default-value-func branch June 1, 2023 11:23
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.

Unable to create a record which has CURRENT_TIMESTAMP() as a default value in its schema
2 participants