-
-
Notifications
You must be signed in to change notification settings - Fork 58
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
why invoke "SHOW VARIABLES LIKE 'auto_increment_increment'" after repo.InsertAll? #304
Comments
because MySQL database driver only returns the last inserted id, and (depending on config), inserted id won't always incremented by 1, therefore we need to know the increment setting to populate the id for the rest of inserted records |
how can i close this feature ? |
do you mean close this issue? or stop using |
stop using "SHOW VARIABLES LIKE 'auto_increment_increment'" query? |
stop using "SHOW VARIABLES LIKE 'auto_increment_increment'" query |
it's not supported at the moment, please open a PR to allow specifying custom increment function |
IncrementFunc only invoke in |
yes |
Can I do that? dsn := fmt.Sprintf(
"%s:%s@tcp(%s:%s)/%s?charset=utf8&parseTime=True&loc=Local",
ko.String("DB_USERNAME"),
ko.String("DB_PASSWORD"),
ko.String("DB_HOST"),
ko.String("DB_PORT"),
ko.String("DB_DATABASE"),
)
adapter, err := mysql.Open(dsn)
if err != nil {
return nil, err
}
sp, ok := adapter.(*sql.SQL)
if !ok {
return nil, errors.New("adapter 获取错误")
}
(*sp).IncrementFunc = nil
return adapter, nil |
I guess you can, just try it |
yes~ |
thanks |
step 1
step 2
why invoke "SHOW VARIABLES LIKE 'auto_increment_increment'" after repo.InsertAll?
The text was updated successfully, but these errors were encountered: