8000 Add failing test for Boolean support of DynamicParameterList · utPLSQL/utPLSQL-java-api@4f591ef · GitHub
[go: up one dir, main page]

Skip to content
8000

Commit 4f591ef

Browse files
committed
Add failing test for Boolean support of DynamicParameterList
1 parent 6100f3c commit 4f591ef

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

src/main/java/org/utplsql/api/db/DynamicParameterList.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,18 @@ public DynamicParameterListBuilder addIfNotEmpty(String identifier, Object[] val
115115
return this;
116116
}
117117

118+
public DynamicParameterListBuilder add(String identifier, Boolean value) {
119+
params.put(identifier, null);
120+
return this;
121+
}
122+
123+
public DynamicParameterListBuilder addIfNotEmpty(String identifier, Boolean value) {
124+
if ( value != null ) {
125+
add(identifier, value);
126+
}
127+
return this;
128+
}
129+
118130
public DynamicParameterList build() {
119131
return new DynamicParameterList(params);
120132
}

src/test/java/org/utplsql/api/db/DynamicParameterListTest.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,20 @@ void can_add_array() throws SQLException {
5959
verify(conn).createOracleArray("MY_TYPE", numArr);
6060
verify(stmt).setArray(3, null);
6161
}
62+
63+
@Test
64+
void can_add_boolean() throws SQLException {
65+
CallableStatement stmt = mock(CallableStatement.class);
66+
67+
DynamicParameterList paramList = DynamicParameterList.builder()
68+
.add("a_bool", true)
69+
.build();
70+
71+
assertEquals("a_param => (case ? when 1 then true else false)", paramList.getSql());
72+
73+
paramList.setParamsStartWithIndex(stmt, 3);
74+
verify(stmt).setInt(3, 1);
75+
}
6276
}
6377

6478
@Nested

0 commit comments

Comments
 (0)
0