volatiletech / sqlboiler

Generate a Go ORM tailored to your database schema.
BSD 3-Clause "New" or "Revised" License
6.73k stars 544 forks source link

provide uuid for binary(16) #529

Closed lelvisl closed 5 years ago

lelvisl commented 5 years ago

How to provide uuid (bd_type: binary(16))?

I'm trying this configuration:

pkgname: dbmodel
output: dbmodel

mysql:
  dbname: DEV
  host: localhost
  port: 3306
  user: user
  pass: pass
  schema: DEV
  sslmode: false
  blacklist: 
  - imp
  types:
  - match:
      db_type: binary
      length: 16
    replace:
      type: uuid.UUID
    imports:
      third_party:
        - '"github.com/satori/go.uuid"'
        # - '"github.com/google/uuid"'

In result:

$ sqlboiler mysql
Error: unable to initialize tables: unable to fetch table data: failed to json-ify driver configuration: json: unsupported type: map[interface {}]interface {}
aarondl commented 5 years ago

Types is not nested under mysql but it's top level. I'd recommend you use TOML for the following reasons:

There was a bug in the parser that only surfaced with yaml (because it has the insane requirement that any object can be a key), I've fixed that.