-
Notifications
You must be signed in to change notification settings - Fork 38.6k
Description
Hans Desmet opened SPR-17483 and commented
The script createDatabases.sql creates two MySQL databases: example1 and example2.
Each database has as table persons:
- The database example1 has as column firstname in this table.
- The database example2 has as column lastname in this table.
The test SimpleJdbcInsertTest tries to insert a record in the database example1.
@RunWith(SpringRunner.class)
@JdbcTest
@AutoConfigureTestDatabase(replace = Replace.NONE)
public class SimpleJdbcInsertTest {
@Autowired
private DataSource dataSource;
private SimpleJdbcInsert insert;
@Before
public void before() {
insert = new SimpleJdbcInsert(dataSource);
}
@Test
public void insertPerson() {
insert.withTableName("persons");
insert.execute(Collections.singletonMap("firstname", "joe"));
}
}
The test fails, because SimpleJdbcInsert sends following statement to the database:
INSERT INTO persons (lastname) VALUES(?)
This statement uses the wrong column lastname from the other database: example2.
The example project uses Spring Boot 2.1.0
When you revert to Spring Boot 2.0.6, the code works.
I think the problem is caused by the way the MySQL JDBC driver 8.0.13 provides meta data has changed, compared to the driver 5.1.47.
I have tried to indiciate this in the test ColumNames, provided in the project.
Affects: 5.1.2
Reference URL: https://github.com/desmethans/simplejdbcinsert.git