# Skip MySQL 5.6 as it does not support generated columns.
! only mysql56

apply 1.hcl
cmphcl 1.inspect.hcl

-- 1.hcl --
schema "$db" {
    charset = "$charset"
    collate = "$collate"
}

table "users" {
    schema = schema.$db
    column "a" {
        type = bool
        null = true
    }
    column "b" {
        type = bool
        null = true
        as = "a"
    }
    column "c" {
        type = bool
        null = true
        as {
            type = STORED
            expr = "b"
        }
    }
    column "d e" {
        null = false
        type = varchar(255)
    }
    column "d $" {
        null = false
        type = varchar(255)
    }
    index "idx_1" {
        columns = [column["d e"]]
    }
    index "idx_2" {
        columns = [column["d $"]]
    }
}

-- 1.inspect.hcl --
table "users" {
  schema = schema.$db
  column "a" {
    null = true
    type = bool
  }
  column "b" {
    null = true
    type = bool
    as {
      expr = "`a`"
      type = VIRTUAL
    }
  }
  column "c" {
    null = true
    type = bool
    as {
      expr = "`b`"
      type = STORED
    }
  }
  column "d e" {
    null = false
    type = varchar(255)
  }
  column "d $" {
    null = false
    type = varchar(255)
  }
  index "idx_1" {
    columns = [column["d e"]]
  }
  index "idx_2" {
    columns = [column["d $"]]
  }
}
schema "$db" {
  charset = "$charset"
  collate = "$collate"
}
