migrate icon indicating copy to clipboard operation
migrate copied to clipboard

JSON field type rejected

Open Jauny opened this issue 3 years ago • 3 comments

Describe the Bug Getting an error when trying to run a migration that creates a field with type JSON.

Steps to Reproduce Steps to reproduce the behavior:

  1. My migrations look like
CREATE TABLE MyTable (
  MyJsonField JSON
)
  1. I ran migrate with the following options
migrate -source file://cmd/db/migrations -database spanner://projects/local-dev-project/instances/local-dev-instance/databases/local-dev-db?x-clean-statements=true up
  1. See error
20220224002042/u initial_table_create (10.983233ms)
error: :18: got "JSON", want scalar type

Expected Behavior We are using Spanner which accepts JSON as valid field type, so I expect the migration to be valid and run.

Migrate Version v4.15.1

Loaded Source Drivers e.g. s3, github, go-bindata, gcs, file Obtained by running: migrate -help

Source drivers: bitbucket, go-bindata, godoc-vfs, gcs, s3, github, github-ee, gitlab, file
Database drivers: neo4j, redshift, spanner, sqlserver, clickhouse, firebirdsql, mongodb+srv, pgx, postgres, postgresql, firebird, mongodb, mysql, cassandra, cockroach, cockroachdb, crdb-postgres, stub

Not explicitly using any except spanner

Go Version go version go1.17.6 darwin/amd64

Stacktrace n/a

Additional context Other migrations without JSON run smoothly up and down (thanks for the great tool!). I'm wondering if I have to do something special for JSON? Not even sure if that error message is coming from this tool or from the Spanner emulator actually :\ Sorry if I'm wasting anyone's time here.

Jauny avatar Mar 04 '22 19:03 Jauny

Confirmed that it's a google spanner emulator issue -

Jauny avatar Mar 04 '22 20:03 Jauny

@Jauny Could you reopen this issue? I think devs need to cut a new migrate release.

This issue is present on the latest release (4.15.1) which used an older spanner lib version, but it's fixed on master because the dependencies were updated.

5 months ago JSON support was added to spansql (https://github.com/googleapis/google-cloud-go/blame/main/spanner/spansql/parser.go#L1893, see blame)

geancarlo avatar Mar 08 '22 18:03 geancarlo

Yes indeed I have cloned the repo and tested from master and indeed we need to cut a new release!

Jauny avatar Mar 11 '22 04:03 Jauny