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

Use TableName to specify the database for the Create operation, but Create will ignore my database name #6252

Closed
chengzixian opened this issue Apr 20, 2023 · 3 comments
Assignees
Labels

Comments

@chengzixian
Copy link

image

Description:
I use 'Attach DATABASE' to attach the database
err = db.Exec("ATTACH DATABASE '" + dsnInfo + "' AS info").Error
So I want to use TableName to specify the database for the Create operation, but Create will ignore my database name
I looked at the source code of Gorm and found that it was caused by the Table method dividing strings with decimal points
How can I keep the database name

中文描述:
我使用来”ATTACH DATABASE“来附加数据库
err = db.Exec("ATTACH DATABASE '" + dsnInfo + "' AS info").Error
所以我想通过TableName来指定数据库来做Create操作, 但是Create会忽略我的数据库名
我看了Gorm的源码, 发现是Table方法以小数点来分割了字符串导致的
我应该怎么才能保留数据库名

@github-actions github-actions bot added the type:missing reproduction steps missing reproduction steps label Apr 20, 2023
@chengzixian
Copy link
Author

源码的具体位置
The specific location of the source code

} else if tables := strings.Split(name, "."); len(tables) == 2 {

@github-actions
Copy link

The issue has been automatically marked as stale as it missing playground pull request link, which is important to help others understand your issue effectively and make sure the issue hasn't been fixed on latest master, checkout https://github.com/go-gorm/playground for details. it will be closed in 30 days if no further activity occurs. if you are asking question, please use the Question template, most likely your question already answered https://github.com/go-gorm/gorm/issues or described in the document https://gorm.ioSearch Before Asking

@a631807682
Copy link
Member

The table name is specified by parse unless you specify it via .Table() (which you don't have in your code).
It cannot be reproduced in the lastest version. If there is still a problem, please provide a reproduction link.

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

3 participants