JSON Parser fails for type override on complex package names
The standard syntax for defining a type override in the lib at the moment is:
"overrides": [
{
"go_type": "github.com/gofrs/uuid.UUID",
"postgres_type": "uuid"
}
]
This results in the following import statement and type (in the struct) in the auto gen code:
import (
"github.com/gofrs/uuid"
)
type test struct {
columnOne uuid.UUID
}
However, the parser fails if the package name containing the desired type override is more complex, for example "gopkg.in/guregu/null.v3".
Have looked at the parser as it is at the moment and the bug fix doesn't look to bad, let me if you want any contribution 👍
I've closed #462 since I'm pretty sure it was a duplicate issue. Is the bug caused by the presence of a dot in the package name?
I've closed #462 since I'm pretty sure it was a duplicate issue.
Is the bug caused by the presence of a dot in the package name?
Correct @Maxiride. The presence of a dot in the package name causes the issue.
Too bad... those packages are my holy grail.
~~Anyway,~~
~~Have looked at the parser as it is at the moment and the bug fix doesn't look to bad, let me if you want any contribution 👍~~
~~@rupertevill did you eventually started working on a PR?~~
As a temporary (hopefully) fix I went down the dangerous path of issuing a replace all in the models and the functions generated.
I went on with a plausible hotfix myself.
This has been fixed in main and will be released in the next version. Here's what it looks like:
{
"version": "1",
"packages": [
{
"path": "go",
"name": "override",
"engine": "postgresql",
"schema": "schema.sql",
"queries": "query.sql",
"overrides": [
{
"column": "foo.bio",
"nullable": true,
"go_type": {
"import": "gopkg.in/guregu/null.v4",
"type": "String"
},
}
]
}
]
}
import (
null_v4 "gopkg.in/guregu/null.v4"
)
type test struct {
columnOne null_v4.String
}