[#1829] Factory.execute(String) may cause errors when plain SQL
returns results
This commit is contained in:
parent
30121c3da2
commit
eaf50d8b57
@ -121,6 +121,15 @@ extends BaseTest<A, AP, B, S, B2S, BS, L, X, DATE, BOOL, D, T, U, I, IPK, T658,
|
||||
assertEquals(BOOK_TITLES, result.getValues(1));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPlainSQLExecuteWithResults() throws Exception {
|
||||
// [#1829] The Factory.execute() method must be able to handle queries
|
||||
// that return results
|
||||
|
||||
assertEquals(0, create().execute(create().render(create().selectOne())));
|
||||
assertEquals(0, create().query(create().render(create().selectOne())).execute());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPlainSQL() throws Exception {
|
||||
jOOQAbstractTest.reset = false;
|
||||
|
||||
@ -884,6 +884,11 @@ public abstract class jOOQAbstractTest<
|
||||
new PlainSQLTests(this).testPlainSQL();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPlainSQLExecuteWithResults() throws Exception {
|
||||
new PlainSQLTests(this).testPlainSQLExecuteWithResults();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPlainSQLAndComments() throws Exception {
|
||||
new PlainSQLTests(this).testPlainSQLAndComments();
|
||||
|
||||
@ -214,11 +214,13 @@ abstract class AbstractQuery extends AbstractQueryPart implements Query, Attacha
|
||||
*/
|
||||
protected int execute(ExecuteContext ctx, ExecuteListener listener) throws SQLException {
|
||||
int result = 0;
|
||||
|
||||
listener.executeStart(ctx);
|
||||
result = ctx.statement().executeUpdate();
|
||||
listener.executeEnd(ctx);
|
||||
|
||||
if (!ctx.statement().execute()) {
|
||||
result = ctx.statement().getUpdateCount();
|
||||
}
|
||||
|
||||
listener.executeEnd(ctx);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user