sqlboiler
sqlboiler copied to clipboard
types aliasing only replaces one type
If you're having a generation problem please answer these questions before submitting your issue. Thanks!
What version of SQLBoiler are you using (sqlboiler --version)?
SQLBoiler v4.14.1
What is your database and version (eg. Postgresql 10)
mysql:8.0.34
If this happened at generation time what was the full SQLBoiler command you used to generate your models? (if not applicable leave blank)
sqlboiler -c sqlboiler.toml mysql
If this happened at runtime what code produced the issue? (if not applicable leave blank)
What is the output of the command above with the -d flag added to it? (Provided you are comfortable sharing this, it contains a blueprint of your schema)
Please provide a relevant database schema so we can replicate your issue (Provided you are comfortable sharing this)
CREATE TABLE IF NOT EXISTS `testing` (
`ID` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`ID`),
`somecol` DECIMAL(10,7) NULL DEFAULT NULL,
`othercol` DECIMAL(10,7) NOT NULL)
ENGINE = InnoDB
AUTO_INCREMENT = 1
DEFAULT CHARACTER SET = utf8mb4
COLLATE = utf8mb4_unicode_ci;
Further information. What did you do, what did you expect?
I tried to add two type replacements in sqlboiler.toml, but only the first one actually did something.
[[types]]
[types.match]
type = "types.Decimal"
[types.replace]
type = "decimal.Decimal"
[types.imports]
third_party = ['"github.com/shopspring/decimal"']
[[types]]
[types.match]
type = "types.NullDecimal"
[types.replace]
type = "decimal.NullDecimal"
[types.imports]
third_party = ['"github.com/shopspring/decimal"']
The resulting Code:
type Testing struct {
ID uint64 `boil:"ID" json:"ID" toml:"ID" yaml:"ID"`
Somecol types.NullDecimal `boil:"somecol" json:"somecol,omitempty" toml:"somecol" yaml:"somecol,omitempty"`
Othercol decimal.Decimal `boil:"othercol" json:"othercol" toml:"othercol" yaml:"othercol"`
R *testingR `boil:"-" json:"-" toml:"-" yaml:"-"`
L testingL `boil:"-" json:"-" toml:"-" yaml:"-"`
}
I would have expected Somecol to be decimal.Nulldecimal.
I am aware that adding replace github.com/ericlagergren/decimal => github.com/ericlagergren/decimal v0.0.0-20181231230500-73749d4874d5 to the go.mod fixes the types.Nulldecimal problems on insert.