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

Hardcoded "postgres" string DB in function openDBConnection() causes table being created in the DB named "postgres" #48

Closed
16pj opened this issue Sep 10, 2020 · 7 comments
Assignees
Labels

Comments

@16pj
Copy link

16pj commented Sep 10, 2020

Sorry I'm new to creating issues here.

file: adapter.go
version tag: 3.02

If the a.dbSpecified is set to true then isn't it expected to use the db name specified in the datasource string, but looks like the hardcoded value "postgres" in openDBConnection() [adapter.go] makes it override the db and uses "postgres" instead.

@hsluoyz
Copy link
Member

hsluoyz commented Sep 10, 2020

@16pj can you make a PR to fix it?

@nodece @GopherJ @00LT00

@hsluoyz hsluoyz self-assigned this Sep 10, 2020
@hsluoyz hsluoyz added the bug label Sep 10, 2020
@00LT00
Copy link
Member

00LT00 commented Sep 10, 2020

Sorry, I forgot. You can add "dbname=xxx" to dsn in order to use normally before I fix this bug. @16pj

@16pj
Copy link
Author

16pj commented Sep 10, 2020

Sorry, I forgot. You can add "dbname=xxx" to dsn in order to use normally before I fix this bug. @16pj

I use dbname but it gets overridden by "dbname=postgres".

@00LT00
Copy link
Member

00LT00 commented Sep 10, 2020

Sorry, I forgot. You can add "dbname=xxx" to dsn in order to use normally before I fix this bug. @16pj

I use dbname but it gets overridden by "dbname=postgres".

Can you tell me where has "dbname=postgres" ?

@nodece
Copy link
Member

nodece commented Sep 10, 2020

@16pj could you provide your code?

@16pj
Copy link
Author

16pj commented Sep 10, 2020

Sorry, I forgot. You can add "dbname=xxx" to dsn in order to use normally before I fix this bug. @16pj

I use dbname but it gets overridden by "dbname=postgres".

Can you tell me where has "dbname=postgres" ?

@00LT00 The hardcoded value is at line 146 of adapter.go tag: 3.0.2. But I see that it might have already been fixed in master 6 days ago by you.

db, err = openDBConnection(a.driverName, a.dataSourceName+" dbname="+a.databaseName)

Thanks

@hsluoyz
Copy link
Member

hsluoyz commented Sep 10, 2020

@16pj so I think this issue can be closed.

@hsluoyz hsluoyz closed this as completed Sep 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants