refactoring: force cast args

This commit is contained in:
2019-06-17 14:13:12 +02:00
parent 00d2fa335d
commit f960e4a66a
4 changed files with 33 additions and 12 deletions

View File

@@ -2,7 +2,7 @@ package fr.postgresjson
import fr.postgresjson.connexion.Connection
import fr.postgresjson.entity.IdEntity
import org.junit.jupiter.api.Assertions.assertTrue
import org.junit.jupiter.api.Assertions.*
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.TestInstance
@@ -46,4 +46,11 @@ class ConnectionTest(): TestAbstract() {
assertTrue(objs[0].id == 1)
assertTrue(objs[0].test!!.id == 1)
}
@Test
fun callRequestWithArgs() {
val result: ObjTest? = connection.selectOne("select json_build_object('id', 1, 'name', ?::text)", listOf("myName"))
assertNotNull(result)
assertEquals("myName", result!!.name)
}
}

View File

@@ -26,7 +26,7 @@ class RequestTest: TestAbstract() {
val objTest: ObjTest? = Requester(getConnextion())
.addFunction(resources)
.getFunction("test_function")
.selectOne(listOf("ploop", "plip"))
.selectOne(listOf("test", "plip"))
assertEquals(objTest!!.id, 3)
assertEquals(objTest.name, "test")
}

View File

@@ -3,6 +3,6 @@ LANGUAGE plpgsql
AS
$$
BEGIN
result = json_build_object('id', 3, 'name', 'test');
result = json_build_object('id', 3, 'name', name);
END;
$$