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

update cloud.google.com/go/spanner to v1.62.0 #58

Merged
merged 2 commits into from
May 19, 2024

Conversation

nametake
Copy link
Contributor

Updated the version of cloud.google.com/go/spanner to v1.62.0.

And, fixed the test cases that were failing due to this update.

Reason

There was an issue with parsing the syntax for foreign key actions in spansql.

Reference: Cloud Spanner Foreign Key Actions

$ cat ./old.sql
CREATE TABLE Artist (
  ID STRING(MAX) NOT NULL,
  Name STRING(MAX) NOT NULL,
  CreatedAt TIMESTAMP NOT NULL OPTIONS (allow_commit_timestamp = true),
) PRIMARY KEY(ID);

CREATE TABLE Album (
  ID STRING(MAX) NOT NULL,
  Title STRING(MAX) NOT NULL,
  ArtistID STRING(MAX) NOT NULL,
  CreatedAt TIMESTAMP NOT NULL OPTIONS (allow_commit_timestamp = true),
  FOREIGN KEY (Artist) REFERENCES Artist (ID) ON DELETE NO ACTION,
) PRIMARY KEY(ID);
$ cat ./new.sql
CREATE TABLE Artist (
  ID STRING(MAX) NOT NULL,
  Name STRING(MAX) NOT NULL,
  CreatedAt TIMESTAMP NOT NULL OPTIONS (allow_commit_timestamp = true),
) PRIMARY KEY(ID);

CREATE TABLE Album (
  ID STRING(MAX) NOT NULL,
  Title STRING(MAX) NOT NULL,
  ArtistID STRING(MAX) NOT NULL,
  CreatedAt TIMESTAMP NOT NULL OPTIONS (allow_commit_timestamp = true),
  FOREIGN KEY (Artist) REFERENCES Artist (ID) ON DELETE NO ACTION,
) PRIMARY KEY(ID);

CREATE TABLE Song (
  ID STRING(MAX) NOT NULL,
  Title STRING(MAX) NOT NULL,
  AlbumID STRING(MAX) NOT NULL,
  CreatedAt TIMESTAMP NOT NULL OPTIONS (allow_commit_timestamp = true),
) PRIMARY KEY(ID);
$ go run main.go diff ./old.sql ./new.sql
Error: ./old.sql failed to parse ddl: ./old.sql:12: got "ON", want ")" or ","
exit status 1

After upgrading, the parsing now succeeds as shown below:

$ go run main.go diff ./old.sql ./new.sql
CREATE TABLE Song (
  ID STRING(MAX) NOT NULL,
  Title STRING(MAX) NOT NULL,
  AlbumID STRING(MAX) NOT NULL,
  CreatedAt TIMESTAMP NOT NULL OPTIONS (allow_commit_timestamp = true),
) PRIMARY KEY(ID);

Actions Taken

  • Ran go get -u cloud.google.com/go/spanner
  • Ran go mod tidy
  • Fixed the tests

@daichirata daichirata merged commit 7cc6a2c into daichirata:master May 19, 2024
6 checks passed
@daichirata
Copy link
Owner

Thank you!

@nametake nametake deleted the update-spanner-v1.62.0 branch May 19, 2024 14:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants