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

imports.based_on_type #323

Closed saulortega closed 6 years ago

saulortega commented 6 years ago

If my model has these imports:

import (
    // ...
    "github.com/volatiletech/sqlboiler/queries/qm"
    "github.com/volatiletech/sqlboiler/strmangle"
    "gopkg.in/volatiletech/null.v7"
)

type Asset struct {
    ID          int64          `boil:"id" json:"id" toml:"id" yaml:"id"`
    DeviceID    null.Int64     `boil:"device_id" json:"device_id,omitempty" toml:"device_id" yaml:"device_id,omitempty"`
    // ...
}

..., after adding this:

[imports.based_on_type."null.Int64"]
  third_party = ['"github.com/saulortega/null"']

I would expect to see this:

import (
    // ...
    "github.com/volatiletech/sqlboiler/queries/qm"
    "github.com/volatiletech/sqlboiler/strmangle"
    "github.com/saulortega/null"
)

type Asset struct {
    ID          int64          `boil:"id" json:"id" toml:"id" yaml:"id"`
    DeviceID    null.Int64     `boil:"device_id" json:"device_id,omitempty" toml:"device_id" yaml:"device_id,omitempty"`
    // ...
}

But that is not happening.

Am I misunderstanding, or how does it work?

aarondl commented 6 years ago

Hey Saul. This was actually a bug. Same thing happened with aliases a litle while back, viper downcases all the identifiers. If you tried to use "string" it would work, but "null.Int64" would not work. There's a new syntax that will allow you to specify an array of tables instead of a table in toml. It's documented in the readme under the imports section. Let me know if you have any other issues here.