Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generation fails when column_type has different namespace/schema than column #1262

Open
them0ntem opened this issue Mar 27, 2023 · 2 comments

Comments

@them0ntem
Copy link

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?

@stephenafamo
Copy link
Collaborator

Kindly share a schema to reproduce

@stephenafamo
Copy link
Collaborator

stephenafamo commented Mar 28, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants