daichirata / hammer

🛠 hammer is a command-line tool to schema management for Google Cloud Spanner.
MIT License
84 stars 25 forks source link

fix UPDATE BYTES to default values #9

Closed nktks closed 4 years ago

nktks commented 4 years ago

Hi!

I fixed case that updating BYTES default value when adding BYTES column with NOT NULL.

reproduce

schema diff

>   bytes BYTES(MAX) NOT NULL,

hammer diff

ALTER TABLE test ADD COLUMN bytes BYTES(MAX)
UPDATE test SET bytes = '' WHERE bytes IS NULL
ALTER TABLE test ALTER COLUMN bytes BYTES(MAX) NOT NULL

hammer apply error

Error: rpc error: code = InvalidArgument desc = Value of type STRING cannot be assigned to bytes, which has type BYTES [at 1:25]\nUPDATE test SET bytes = \'\' WHERE bytes IS NULL\n
daichirata commented 4 years ago

thank you so much 👍