Check db execute MySQL behaviour
Error reporting
Missing final semicolon (it is OK)
@@ -82,3 +82,44 @@ fn db_execute_happy_path_with_prisma_schema(api: TestApi) {
assert_eq!(rows.next().unwrap()[0].to_string().unwrap(), "snoopy");
assert_eq!(rows.next().unwrap()[0].to_string().unwrap(), "marmaduke");
}
+
+#[test_connector(tags(Mysql))]
+fn mysql_incomplete_script_works(api: TestApi) {
+ let script = r#"
+ CREATE TABLE `dogs` ( id INTEGER AUTO_INCREMENT PRIMARY KEY, name TEXT );
+ INSERT INTO `dogs` (`name`) VALUES ('snoopy'), ('marmaduke') -- missing final semicolon
+ "#;
+
+ let url = api.connection_string().to_owned();
+
+ // Execute the command.
+ api.db_execute(&DbExecuteParams {
+ datasource_type: DbExecuteDatasourceType::Url(UrlContainer { url: url.clone() }),
+ script: script.to_owned(),
+ })
+ .unwrap();
+
+ // Check that the command was executed
+ let q = api.block_on(quaint::single::Quaint::new(&url)).unwrap();
+ let result = api.block_on(q.query_raw("SELECT name FROM dogs;", &[])).unwrap();
+ let mut rows = result.into_iter();
+ assert_eq!(rows.next().unwrap()[0].to_string().unwrap(), "snoopy");
+ assert_eq!(rows.next().unwrap()[0].to_string().unwrap(), "marmaduke");
+}
+
+#[test_connector(tags(Mysql))]
+fn db_execute_error_path(api: TestApi) {
+ let script = r#"
+ CREATE TABLE "dogs" ( id INTEGER AUTO_INCREMENT PRIMARY KEY, name TEXT );
+ "#;
+
+ // Execute the command.
+ let result = api.db_execute(&DbExecuteParams {
+ datasource_type: DbExecuteDatasourceType::Url(UrlContainer {
+ url: api.connection_string().to_owned(),
+ }),
+ script: script.to_owned(),
+ });
+
+ assert!(result.is_err());
+}
