yamldb/yaml_db

dump/load doesn't work with MySQL virtual columns

octavpo opened this issue · 0 comments

I have a table that looks like:

    create_table :skills do |t|
      t.string :name, null: false
      t.string :category, null: false
      t.virtual :identity, type: :string, as: "concat_ws('/', name, category)"
      ...
    end

db:data:dump dumps the virtual column values fine, but when I try to load them with db:data:load I get an error from MySQL:

Mysql2::Error: The value specified for generated column 'identity' in table 'skills' is not allowed.

It looks like MySQL wants to recreate the virtual values dynamically on load, so it doesn't accept values being given for them in INSERT. After I deleted the values from the data.yaml file, I could load it fine.

So the utility should either skip virtual columns on dump, or skip them on load.