You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-- MySQL dump 10.19 Distrib 10.3.32-MariaDB, for debian-linux-gnu (x86_64)---- Host: 127.0.0.1 Database: test-db-- -------------------------------------------------------- Server version 10.4.16-MariaDB-1:10.4.16+maria~focal/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
---- SQL statements here...--/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2022-01-03 16:24:14
It seems as if the conditional statements like /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; are ignored when using the withInitScript() method. In my case, the result is that the foreign key checks are not disabled when running the script.
When explicitly using SET FOREIGN_KEY_CHECKS = 0; or SET FOREIGN_KEY_CHECKS = 1; then the database can be created successfully.
The text was updated successfully, but these errors were encountered:
Support for more advanced SQL syntax in withInitScript() is limited, also see this similar issue for PostgreSQL: #4441
In such advanced cases, I would suggest using dedicated tools db initialization, such as Flyway or Liquibase, since it is unlikely that withInitScript() will support all SQL dialects completely.
Just curious here but why does testcontainers need to "support" vendor specific SQL ? Isn't it just passing through whatever the init script contains ? The database can then deal with unknown SQL as it sees fit...
Using Testcontainers 1.16.3 I have the following static setup method for a MariaDB 10.4 image:
This is the
init.sql
script:It seems as if the conditional statements like
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
are ignored when using thewithInitScript()
method. In my case, the result is that the foreign key checks are not disabled when running the script.When explicitly using
SET FOREIGN_KEY_CHECKS = 0;
orSET FOREIGN_KEY_CHECKS = 1;
then the database can be created successfully.The text was updated successfully, but these errors were encountered: