Sourabh Rawat
01/16/2022, 3:04 PM@Test
fun dbTest2() {
Database.connect("jdbc:h2:mem:test", driver = "org.h2.Driver")
transaction {
SchemaUtils.create(Blogs)
}
transaction {
Blog.all().also { println(it.toList()) }
Blog.new {
title = "asd"
rawContent = "foo"
}
Blog.all().also { println(it.toList()) }
}
}
with Table "BLOGS" not found (this database is empty)
even though I can see that create table call executed before
2022-01-16 20:32:57.273 [Test worker] DEBUG Exposed - CREATE TABLE IF NOT EXISTS BLOGS (ID INT AUTO_INCREMENT PRIMARY KEY, TITLE VARCHAR(100) NOT NULL, RAW_CONTENT TEXT NOT NULL, CREATE_DATE_TIME DATETIME(9) NOT NULL, UPDATE_DATE_TIME DATETIME(9) NOT NULL)
2022-01-16 20:32:57.289 [Test worker] DEBUG Exposed - SELECT BLOGS.ID, BLOGS.TITLE, BLOGS.RAW_CONTENT, BLOGS.CREATE_DATE_TIME, BLOGS.UPDATE_DATE_TIME FROM BLOGS
jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;
works