-
Notifications
You must be signed in to change notification settings - Fork 532
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
psql driver - can't read configs - found key user in config, but it was not a string (<nil>) #830
Comments
I'm quite unsure what's going on here. Have you recompiled your postgres driver recently? File permissions are okay? You're certain that it's finding the correct config file? (With no arguments it will use sqlboiler.toml in the current dir) |
If I run sqlboiler with MySQL everything works fine with a config file in current directory, but when I use psql it can't map the config file!!! |
You missed answering one of my questions.
|
Sorry, no I didn't, I just downloaded the driver as you said in Readme # Install sqlboiler v4
GO111MODULE=off go get -u -t github.com/volatiletech/sqlboiler
# Install a sqlboiler driver - these are separate binaries, here we are
# choosing postgresql
GO111MODULE=off go get github.com/volatiletech/sqlboiler/drivers/sqlboiler-psql with MySQL everything works fine sqlboiler mysql -d
using driver: /Users/hasanein/go/bin/sqlboiler-mysql
{"config":{"driver_name":"mysql","driver_config":{"blacklist":["migrations","other"],"dbname":"dbname".... but for psql it doesn't, all config fields are null... sqlboiler psql -d
using driver: /Users/hasanein/go/bin/sqlboiler-psql
found key user in config, but it was not a string (<nil>)
{"config":{"driver_name":"psql","driver_config":{"blacklist":null,"dbname":null,"host":null,"pass":null,"port":null... this is the sample file: output = "psql_models"
wipe = true
no-tests = true
[psql]
dbname = "dbname"
host = "localhost"
port = 5432
user = "dbusername"
pass = "dbpassword"
schema = "myschema"
blacklist = ["migrations", "other"]
[mysql]
dbname = "dbname"
host = "localhost"
port = 3306
user = "dbusername"
pass = "dbpassword"
sslmode = "false"
blacklist = ["migrations", "other"] |
Sorry @kolahjoub this has got me stumped. I can't reproduce this at all. I suggest deleting all the sqlboiler source code on your machine. Meaning you should do:
And reinstall. As far as I'm considered this is a local issue and you're going to have to sort it out so I'm going to close this. |
For those who may face this issue in the future, I had an Environment Variable $PSQL="/paht/to/postgresql/". |
Hi, I had same problem on mysql. in code at main.go#allKeys, reads Environment Variables and set values to driver_config. so, if have Environment MYSQL or PSQL, etc causes this error. |
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.2.0
What is your database and version (eg. Postgresql 10)
psql (PostgreSQL) 11.8
What is your sqlboiler.toml file?
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
Further information. What did you do, what did you expect?
I expect that Sqlboiler parses the config file but it doesn't. Everything works with MySQL config file, but with the psql config, sqlboiler throws an error:
found key user in config, but it was not a 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)sqlboiler psql -d
using driver: /Users/hasanein/go/bin/sqlboiler-psql
found key user in config, but it was not a string ()
{"config":{"driver_name":"psql","driver_config":{"blacklist":null,"dbname":null,"host":null,"pass":null,"port":null,"user":null,"whitelist":null},"pkg_name":"models","out_folder":"psql_models","debug":true,"no_tests":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"",""io/ioutil"",""math/rand"",""regexp""],"ThirdParty":[""github.com/volatiletech/sqlboiler/v4/boil""]},"boil_suites_test":{"Standard":[""testing""],"ThirdParty":null}}},"aliases":{},"version":"4.2.0"},"driver_config":{"blacklist":null,"dbname":null,"host":null,"pass":null,"port":null,"user":null,"whitelist":null},"schema":"","dialect":{"lq":0,"rq":0,"use_index_placeholders":false,"use_last_insert_id":false,"use_schema":false,"use_default_keyword":false,"use_auto_columns":false,"use_top_clause":false,"use_output_clause":false,"use_case_when_exists_clause":false},"tables":null,"templates":null}
Error: exit status 1
driver (/Users/hasanein/go/bin/sqlboiler-psql) exited non-zero
github.com/volatiletech/sqlboiler/drivers.execute
/Users/hasanein/go/src/github.com/volatiletech/sqlboiler/drivers/binary_driver.go:73
github.com/volatiletech/sqlboiler/drivers.binaryDriver.Assemble
/Users/hasanein/go/src/github.com/volatiletech/sqlboiler/drivers/binary_driver.go:21
github.com/volatiletech/sqlboiler/boilingcore.(*State).initDBInfo
/Users/hasanein/go/src/github.com/volatiletech/sqlboiler/boilingcore/boilingcore.go:382
github.com/volatiletech/sqlboiler/boilingcore.New
/Users/hasanein/go/src/github.com/volatiletech/sqlboiler/boilingcore/boilingcore.go:93
main.preRun
/Users/hasanein/go/src/github.com/volatiletech/sqlboiler/main.go:213
github.com/spf13/cobra.(*Command).execute
/Users/hasanein/go/src/github.com/spf13/cobra/command.go:839
github.com/spf13/cobra.(*Command).ExecuteC
/Users/hasanein/go/src/github.com/spf13/cobra/command.go:958
github.com/spf13/cobra.(*Command).Execute
/Users/hasanein/go/src/github.com/spf13/cobra/command.go:895
main.main
/Users/hasanein/go/src/github.com/volatiletech/sqlboiler/main.go:122
runtime.main
/usr/local/go/src/runtime/proc.go:204
runtime.goexit
/usr/local/go/src/runtime/asm_amd64.s:1374
unable to fetch table data
github.com/volatiletech/sqlboiler/boilingcore.(*State).initDBInfo
/Users/hasanein/go/src/github.com/volatiletech/sqlboiler/boilingcore/boilingcore.go:384
github.com/volatiletech/sqlboiler/boilingcore.New
/Users/hasanein/go/src/github.com/volatiletech/sqlboiler/boilingcore/boilingcore.go:93
main.preRun
/Users/hasanein/go/src/github.com/volatiletech/sqlboiler/main.go:213
github.com/spf13/cobra.(*Command).execute
/Users/hasanein/go/src/github.com/spf13/cobra/command.go:839
github.com/spf13/cobra.(*Command).ExecuteC
/Users/hasanein/go/src/github.com/spf13/cobra/command.go:958
github.com/spf13/cobra.(*Command).Execute
/Users/hasanein/go/src/github.com/spf13/cobra/command.go:895
main.main
/Users/hasanein/go/src/github.com/volatiletech/sqlboiler/main.go:122
runtime.main
/usr/local/go/src/runtime/proc.go:204
runtime.goexit
/usr/local/go/src/runtime/asm_amd64.s:1374
unable to initialize tables
github.com/volatiletech/sqlboiler/boilingcore.New
/Users/hasanein/go/src/github.com/volatiletech/sqlboiler/boilingcore/boilingcore.go:95
main.preRun
/Users/hasanein/go/src/github.com/volatiletech/sqlboiler/main.go:213
github.com/spf13/cobra.(*Command).execute
/Users/hasanein/go/src/github.com/spf13/cobra/command.go:839
github.com/spf13/cobra.(*Command).ExecuteC
/Users/hasanein/go/src/github.com/spf13/cobra/command.go:958
github.com/spf13/cobra.(*Command).Execute
/Users/hasanein/go/src/github.com/spf13/cobra/command.go:895
main.main
/Users/hasanein/go/src/github.com/volatiletech/sqlboiler/main.go:122
runtime.main
/usr/local/go/src/runtime/proc.go:204
runtime.goexit
/usr/local/go/src/runtime/asm_amd64.s:1374
The text was updated successfully, but these errors were encountered: