sqlboiler icon indicating copy to clipboard operation
sqlboiler copied to clipboard

Generation fails when column_type has different namespace/schema than column

Open them0ntem opened this issue 2 years ago • 2 comments

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

SQLBoiler v4.14.1

What is your database and version (eg. Postgresql 10)

PostgreSQL 13.6

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

sqlboiler psql --debug --config sqlboiler.toml

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)

unable to load tables: unable to fetch table column info (roles): unable to scan for table roles: sql: Scan error on column index 1, name "column_type": converting NULL to string is unsupported
{"config":{"driver_name":"psql","driver_config":{"add-enum-types":true,"blacklist":null,"dbname":"pipeline","enum-null-prefix":"Null","host":"localhost","pass":"--","port":5432,"schema":"public","sslmode":"disable","user":"--","whitelist":["user_role_mapping","roles"]},"pkg_name":"publicdb","out_folder":"pkg/models/database/public","debug":true,"add_soft_deletes":true,"add_enum_types":true,"enum_null_prefix":"Null","no_tests":true,"no_auto_timestamps":true,"wipe":true,"struct_tag_casing":"snake","relation_tag":"-","imports":{"all":{"Standard":["\"database/sql\"","\"fmt\"","\"reflect\"","\"strings\"","\"sync\"","\"time\""],"ThirdParty":["\"github.com/friendsofgo/errors\"","\"github.com/volatiletech/sqlboiler/v4/boil\"","\"github.com/volatiletech/sqlboiler/v4/queries\"","\"github.com/volatiletech/sqlboiler/v4/queries/qm\"","\"github.com/volatiletech/sqlboiler/v4/queries/qmhelper\"","\"github.com/volatiletech/strmangle\""]},"test":{"Standard":["\"bytes\"","\"reflect\"","\"testing\""],"ThirdParty":["\"github.com/volatiletech/sqlboiler/v4/boil\"","\"github.com/volatiletech/sqlboiler/v4/queries\"","\"github.com/volatiletech/randomize\"","\"github.com/volatiletech/strmangle\""]},"singleton":{"boil_queries":{"Standard":null,"ThirdParty":["\"github.com/volatiletech/sqlboiler/v4/drivers\"","\"github.com/volatiletech/sqlboiler/v4/queries\"","\"github.com/volatiletech/sqlboiler/v4/queries/qm\""]},"boil_types":{"Standard":["\"strconv\""],"ThirdParty":["\"github.com/friendsofgo/errors\"","\"github.com/volatiletech/sqlboiler/v4/boil\"","\"github.com/volatiletech/strmangle\""]}},"test_singleton":{"boil_main_test":{"Standard":["\"database/sql\"","\"flag\"","\"fmt\"","\"math/rand\"","\"os\"","\"path/filepath\"","\"strings\"","\"testing\"","\"time\""],"ThirdParty":["\"github.com/spf13/viper\"","\"github.com/volatiletech/sqlboiler/v4/boil\""]},"boil_queries_test":{"Standard":["\"bytes\"","\"fmt\"","\"io\"","\"math/rand\"","\"regexp\""],"ThirdParty":["\"github.com/volatiletech/sqlboiler/v4/boil\""]},"boil_suites_test":{"Standard":["\"testing\""],"ThirdParty":null}}},"aliases":{},"auto_columns":{},"inflections":{"Plural":{},"PluralExact":{},"Singular":{},"SingularExact":{},"Irregular":{}},"version":"4.14.1"},"driver_config":{"add-enum-types":true,"blacklist":null,"dbname":"pipeline","enum-null-prefix":"Null","host":"localhost","pass":"--","port":5432,"schema":"public","sslmode":"disable","user":"--","whitelist":["user_role_mapping","roles"]},"schema":"","dialect":{"lq":0,"rq":0,"use_index_placeholders":false,"use_last_insert_id":false,"use_schema":false,"use_default_keyword":false,"use_top_clause":false,"use_output_clause":false,"use_case_when_exists_clause":false,"use_auto_columns":false},"tables":null,"templates":null}
Error: exit status 1
driver (C:\Users\manthan.sharma\go\bin\sqlboiler-psql.exe) exited non-zero
github.com/volatiletech/sqlboiler/v4/drivers.execute
        C:/Users/manthan.sharma/go/pkg/mod/github.com/volatiletech/sqlboiler/[email protected]/drivers/binary_driver.go:73
github.com/volatiletech/sqlboiler/v4/drivers.binaryDriver.Assemble
        C:/Users/manthan.sharma/go/pkg/mod/github.com/volatiletech/sqlboiler/[email protected]/drivers/binary_driver.go:21
github.com/volatiletech/sqlboiler/v4/boilingcore.(*State).initDBInfo
        C:/Users/manthan.sharma/go/pkg/mod/github.com/volatiletech/sqlboiler/[email protected]/boilingcore/boilingcore.go:408
github.com/volatiletech/sqlboiler/v4/boilingcore.New
        C:/Users/manthan.sharma/go/pkg/mod/github.com/volatiletech/sqlboiler/[email protected]/boilingcore/boilingcore.go:86
main.preRun
        C:/Users/manthan.sharma/go/pkg/mod/github.com/volatiletech/sqlboiler/[email protected]/main.go:219
github.com/spf13/cobra.(*Command).execute
        C:/Users/manthan.sharma/go/pkg/mod/github.com/spf13/[email protected]/command.go:857
github.com/spf13/cobra.(*Command).ExecuteC
        C:/Users/manthan.sharma/go/pkg/mod/github.com/spf13/[email protected]/command.go:990
github.com/spf13/cobra.(*Command).Execute
        C:/Users/manthan.sharma/go/pkg/mod/github.com/spf13/[email protected]/command.go:918
main.main
        C:/Users/manthan.sharma/go/pkg/mod/github.com/volatiletech/sqlboiler/[email protected]/main.go:122
runtime.main
        C:/Program Files/Go/src/runtime/proc.go:250
runtime.goexit
        C:/Program Files/Go/src/runtime/asm_amd64.s:1598
unable to fetch table data
github.com/volatiletech/sqlboiler/v4/boilingcore.(*State).initDBInfo
        C:/Users/manthan.sharma/go/pkg/mod/github.com/volatiletech/sqlboiler/[email protected]/boilingcore/boilingcore.go:410
github.com/volatiletech/sqlboiler/v4/boilingcore.New
        C:/Users/manthan.sharma/go/pkg/mod/github.com/volatiletech/sqlboiler/[email protected]/boilingcore/boilingcore.go:86
main.preRun
        C:/Users/manthan.sharma/go/pkg/mod/github.com/volatiletech/sqlboiler/[email protected]/main.go:219
github.com/spf13/cobra.(*Command).execute
        C:/Users/manthan.sharma/go/pkg/mod/github.com/spf13/[email protected]/command.go:857
github.com/spf13/cobra.(*Command).ExecuteC
        C:/Users/manthan.sharma/go/pkg/mod/github.com/spf13/[email protected]/command.go:990
github.com/spf13/cobra.(*Command).Execute
        C:/Users/manthan.sharma/go/pkg/mod/github.com/spf13/[email protected]/command.go:918
main.main
        C:/Users/manthan.sharma/go/pkg/mod/github.com/volatiletech/sqlboiler/[email protected]/main.go:122
runtime.main
        C:/Program Files/Go/src/runtime/proc.go:250
runtime.goexit
        C:/Program Files/Go/src/runtime/asm_amd64.s:1598
unable to initialize tables
github.com/volatiletech/sqlboiler/v4/boilingcore.New
        C:/Users/manthan.sharma/go/pkg/mod/github.com/volatiletech/sqlboiler/[email protected]/boilingcore/boilingcore.go:88
main.preRun
        C:/Users/manthan.sharma/go/pkg/mod/github.com/volatiletech/sqlboiler/[email protected]/main.go:219
github.com/spf13/cobra.(*Command).execute
        C:/Users/manthan.sharma/go/pkg/mod/github.com/spf13/[email protected]/command.go:857
github.com/spf13/cobra.(*Command).ExecuteC
        C:/Users/manthan.sharma/go/pkg/mod/github.com/spf13/[email protected]/command.go:990
github.com/spf13/cobra.(*Command).Execute
        C:/Users/manthan.sharma/go/pkg/mod/github.com/spf13/[email protected]/command.go:918
main.main
        C:/Users/manthan.sharma/go/pkg/mod/github.com/volatiletech/sqlboiler/[email protected]/main.go:122
runtime.main
        C:/Program Files/Go/src/runtime/proc.go:250
runtime.goexit
        C:/Program Files/Go/src/runtime/asm_amd64.s:1598

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

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

them0ntem avatar Mar 27 '23 16:03 them0ntem

Kindly share a schema to reproduce

stephenafamo avatar Mar 27 '23 19:03 stephenafamo

At the moment, SQLBoiler is not cross-schema aware, so there is no good way to handle this right now. I'll label this as a feature request since it is currently working as intended.

For v5, perhaps we could consider making SQLBoiler cross-schema aware.


If you are working on an entirely new project, I would suggest considering Bob which is heavily inspired by SQLBoiler and is cross-schema aware.

stephenafamo avatar Mar 28 '23 14:03 stephenafamo