go-testfixtures / testfixtures

Ruby on Rails like test fixtures for Go. Write tests against a real database
https://pkg.go.dev/github.com/go-testfixtures/testfixtures/v3?tab=doc
MIT License
1.12k stars 80 forks source link

MySQL doesn't support multiple statements #240

Open wxiaoguang opened 2 weeks ago

wxiaoguang commented 2 weeks ago

This change is not right. MySQL doesn't work that way.

LoadFixtures failed after retries: Error 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ALTER TABLE `issue` AUTO_INCREMENT = 10000;ALTER TABLE `release` AUTO_INCREMENT ' at line 1

_Originally posted by @wxiaoguang in https://github.com/go-testfixtures/testfixtures/pull/208#discussion_r1823778648_


Well ... see the REAMDE: ?multiStatements=true but it is not a good approach. It makes the tests different from the production config.

The testfixtures should use the same connection parameters as production IMO

slsyy commented 2 weeks ago

I will think about solution

The testfixtures should use the same connection parameters as production IMO

You can use a separate connection for testfixtures. It won't work in transaction though