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

feat: reset sequences in one exec #208

Merged

Conversation

slsyy
Copy link
Contributor

@slsyy slsyy commented Jun 27, 2024

to make it faster

@andreynering andreynering enabled auto-merge (squash) July 13, 2024 20:42
@andreynering
Copy link
Contributor

@slsyy 🚀

@andreynering andreynering merged commit 6d9bdb6 into go-testfixtures:master Jul 13, 2024
2 checks passed
if _, err := db.Exec(fmt.Sprintf("ALTER TABLE %s AUTO_INCREMENT = %d", h.quoteKeyword(t), resetSequencesTo)); err != nil {
return err
}
b.WriteString(fmt.Sprintf("ALTER TABLE %s AUTO_INCREMENT = %d;", h.quoteKeyword(t), resetSequencesTo))

This comment was marked as resolved.

@kolaente
Copy link
Contributor

kolaente commented Dec 19, 2024

This seems to cause failures when using testfixtures with mysql:

Error 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'ALTER TABLE `task_buckets` AUTO_INCREMENT = 10000;ALTER TABLE `task_positions...' at line 1

slsyy added a commit to slsyy/testfixtures that referenced this pull request Dec 22, 2024
The go-testfixtures#208 PR introduced an optimisation, which requires the
`multiStatements=true` parameter in connection string to work properly

It looks like that the requirement for that parameter (which is stated
in `README.md`) was not honored by users (e.g go-testfixtures#240), so I want to
keep the old behavior for convienience

This commit:
* remove mention about parameter requirement from `README.md`
* revert default to `one query per one statement`
* allows to keep `one query per multiple statements` logic with a
  `testfixtures.AllowMultipleStatementsInOneQuery` flag
* some tests for both use cases
slsyy added a commit to slsyy/testfixtures that referenced this pull request Dec 22, 2024
The go-testfixtures#208 PR introduced an optimisation, which requires the
`multiStatements=true` parameter in connection string to work properly

It looks like that the requirement for that parameter (which is stated
in `README.md`) was not honored by users (e.g go-testfixtures#240), so I want to
keep the old behavior for convenience

This commit:
* remove mention about parameter requirement from `README.md`
* revert default to `one query per one statement`
* allows to keep `one query per multiple statements` logic with a
  `testfixtures.AllowMultipleStatementsInOneQuery` flag
* some tests for both use cases
slsyy added a commit that referenced this pull request Dec 22, 2024
The #208 PR introduced an optimisation, which requires the
`multiStatements=true` parameter in connection string to work properly

It looks like that the requirement for that parameter (which is stated
in `README.md`) was not honored by users (e.g #240), so I want to
keep the old behavior for convenience

This commit:
* remove mention about parameter requirement from `README.md`
* revert default to `one query per one statement`
* allows to keep `one query per multiple statements` logic with a
  `testfixtures.AllowMultipleStatementsInOneQuery` flag
* some tests for both use cases
@slsyy
Copy link
Contributor Author

slsyy commented Dec 22, 2024

@kolaente
Copy link
Contributor

Seems to work, thanks!

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

Successfully merging this pull request may close these issues.

4 participants