volatiletech / sqlboiler

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

user defined types that are not enums break generation #131

Closed makslevental closed 7 years ago

makslevental commented 7 years ago

fixed here https://github.com/vattle/sqlboiler/pull/133

What version of SQLBoiler are you using (sqlboiler --version)?

2.2.0

If this happened at generation time what was the full SQLBoiler command you used to generate your models? (if not applicable leave blank)

sqlboiler postgres

If this happened at runtime what code produced the issue? (if not applicable leave blank)

Error: unable to initialize tables: unable to fetch table data: unable to fetch table column info (slot): unable to scan for table slot: sql: Scan error on column index 1: unsupported Scan, storing driver.Value type <nil> into type *string

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)

Error: sql: Scan error on column index 1: unsupported Scan, storing driver.Value type <nil> into type *string unable to scan for table slot_release github.com/vattle/sqlboiler/bdb/drivers.(*PostgresDriver).Columns /home/maksim/dev_projects/go/src/github.com/vattle/sqlboiler/bdb/drivers/postgres.go:190 github.com/vattle/sqlboiler/bdb.Tables /home/maksim/dev_projects/go/src/github.com/vattle/sqlboiler/bdb/interface.go:50 github.com/vattle/sqlboiler/boilingcore.(*State).initTables /home/maksim/dev_projects/go/src/github.com/vattle/sqlboiler/boilingcore/boilingcore.go:326 github.com/vattle/sqlboiler/boilingcore.New /home/maksim/dev_projects/go/src/github.com/vattle/sqlboiler/boilingcore/boilingcore.go:66 main.preRun /home/maksim/dev_projects/go/src/github.com/vattle/sqlboiler/main.go:258 github.com/spf13/cobra.(*Command).execute /home/maksim/dev_projects/go/src/github.com/spf13/cobra/command.go:623 github.com/spf13/cobra.(*Command).ExecuteC /home/maksim/dev_projects/go/src/github.com/spf13/cobra/command.go:710 github.com/spf13/cobra.(*Command).Execute /home/maksim/dev_projects/go/src/github.com/spf13/cobra/command.go:669 main.main /home/maksim/dev_projects/go/src/github.com/vattle/sqlboiler/main.go:102 runtime.main /home/maksim/go/src/runtime/proc.go:185 runtime.goexit /home/maksim/go/src/runtime/asm_amd64.s:2197 unable to fetch table column info (slot_release) github.com/vattle/sqlboiler/bdb.Tables /home/maksim/dev_projects/go/src/github.com/vattle/sqlboiler/bdb/interface.go:51 github.com/vattle/sqlboiler/boilingcore.(*State).initTables /home/maksim/dev_projects/go/src/github.com/vattle/sqlboiler/boilingcore/boilingcore.go:326 github.com/vattle/sqlboiler/boilingcore.New /home/maksim/dev_projects/go/src/github.com/vattle/sqlboiler/boilingcore/boilingcore.go:66 main.preRun /home/maksim/dev_projects/go/src/github.com/vattle/sqlboiler/main.go:258 github.com/spf13/cobra.(*Command).execute /home/maksim/dev_projects/go/src/github.com/spf13/cobra/command.go:623 github.com/spf13/cobra.(*Command).ExecuteC /home/maksim/dev_projects/go/src/github.com/spf13/cobra/command.go:710 github.com/spf13/cobra.(*Command).Execute /home/maksim/dev_projects/go/src/github.com/spf13/cobra/command.go:669 main.main /home/maksim/dev_projects/go/src/github.com/vattle/sqlboiler/main.go:102 runtime.main /home/maksim/go/src/runtime/proc.go:185 runtime.goexit /home/maksim/go/src/runtime/asm_amd64.s:2197 unable to fetch table data github.com/vattle/sqlboiler/boilingcore.(*State).initTables /home/maksim/dev_projects/go/src/github.com/vattle/sqlboiler/boilingcore/boilingcore.go:328 github.com/vattle/sqlboiler/boilingcore.New /home/maksim/dev_projects/go/src/github.com/vattle/sqlboiler/boilingcore/boilingcore.go:66 main.preRun /home/maksim/dev_projects/go/src/github.com/vattle/sqlboiler/main.go:258 github.com/spf13/cobra.(*Command).execute /home/maksim/dev_projects/go/src/github.com/spf13/cobra/command.go:623 github.com/spf13/cobra.(*Command).ExecuteC /home/maksim/dev_projects/go/src/github.com/spf13/cobra/command.go:710 github.com/spf13/cobra.(*Command).Execute /home/maksim/dev_projects/go/src/github.com/spf13/cobra/command.go:669 main.main /home/maksim/dev_projects/go/src/github.com/vattle/sqlboiler/main.go:102 runtime.main /home/maksim/go/src/runtime/proc.go:185 runtime.goexit /home/maksim/go/src/runtime/asm_amd64.s:2197 unable to initialize tables github.com/vattle/sqlboiler/boilingcore.New /home/maksim/dev_projects/go/src/github.com/vattle/sqlboiler/boilingcore/boilingcore.go:68 main.preRun /home/maksim/dev_projects/go/src/github.com/vattle/sqlboiler/main.go:258 github.com/spf13/cobra.(*Command).execute /home/maksim/dev_projects/go/src/github.com/spf13/cobra/command.go:623 github.com/spf13/cobra.(*Command).ExecuteC /home/maksim/dev_projects/go/src/github.com/spf13/cobra/command.go:710 github.com/spf13/cobra.(*Command).Execute /home/maksim/dev_projects/go/src/github.com/spf13/cobra/command.go:669 main.main /home/maksim/dev_projects/go/src/github.com/vattle/sqlboiler/main.go:102 runtime.main /home/maksim/go/src/runtime/proc.go:185 runtime.goexit /home/maksim/go/src/runtime/asm_amd64.s:2197

Please provide a relevant database schema so we can replicate your issue (Provided you are comfortable sharing this)

https://github.com/databrary/databrary/blob/master/schema.sql

Further information. What did you do, what did you expect?

expected model generation to work

aarondl commented 7 years ago

As the title says, this breaks if UDT's aren't enums. So I just made the case statement smarter. I'm not sure why it was originally like it was. This is fixed on the dev branch, however your database doesn't generate because of missing primary keys.

Segment because it's not supported by the driver there's warnings and it becomes a string. This probably isn't desirable.

Like I said I'd very much like to rip the current model we have for database drivers out and replace it by something pluggable. I have every intention of doing this sooner rather than later as with the addition of MSSQL and now maybe even SQLite it's starting to get burdensome for our users to have to install so many drivers when they really could care less about three of them in most cases. I'm opened to sharing this work if you were interested in speeding it up (I'm gone for most of the weekend and so won't be working on it.)

makslevental commented 7 years ago

@aarondl pretty green when it comes to go dev but if you don't have a problem with that then definitely wouldn't mind helping. i've explored the code base pretty thoroughly implementing my own custom types hack so i don't think i'd have too much trouble.