获取插入返回值
方式一:构造OQL
@Test
fun testInsertOQLWidthKeys() {
val book2 = TestBook()
book2.testName = "abcInsertOQLWidthKeys"
book2.testURL = "InsertOQLWidthKeys"
val q = OQL.From(book2).Insert(book2.testName, book2.testURL).END
val keysInserted = getDB().insert(q, true)
println("InsertOQL新插入条目的ID = ${keysInserted}")
Assert.assertTrue("$keysInserted".isNotBlank())
}
|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| finalSql | INSERT INTO `test_book` |
| | |
| | (`test_name`,`test_url`,`created_at`,`updated_at`,`created_by`,`updated_by`,`test_id`) |
| | |
| | Values |
| | |
| | ('abcInsertOQLWidthKeys','InsertOQLWidthKeys','2017-05-17T20:48:52.330','2017-05-17T20:48:52.330','zhangsanfeng','zhangsanfeng','17170652049657856') |
|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
方式二 :插入Entity
@Test
fun testInsertEntityWidthKeys() {
val book2 = TestBook()
book2.testName = "abc"
book2.testURL = "22222"
val keysInserted = getDB().insert(book2)
println("InsertEntity新插入条目的ID = ${keysInserted}")
Assert.assertTrue("$keysInserted".isNotBlank())
}
|-------------------------------------------------------------------------------------------------------------------------------------------|
| finalSql | INSERT INTO `test_book` |
| | |
| | (`created_at`,`updated_at`,`created_by`,`updated_by`,`test_name`,`test_url`,`test_id`) |
| | |
| | Values |
| | |
| | ('2017-05-17T20:48:52.063','2017-05-17T20:48:52.063','zhangsanfeng','zhangsanfeng','abc','22222','17170647750496256') |
|-------------------------------------------------------------------------------------------------------------------------------------------|