[jOOQ/jOOQ#8897] Fix INSERT .. RETURNING for Oracle

INSERT .. RETURNING emulation doesn't work on Oracle for single row inserts when returning expressions
This commit is contained in:
Lukas Eder 2019-07-04 13:52:19 +02:00
parent b20658f262
commit d6bf5a8fe1
5 changed files with 48 additions and 23 deletions

View File

@ -498,11 +498,20 @@ abstract class AbstractDMLQuery<R extends Record> extends AbstractRowCountQuery
ctx.data().remove(DATA_DML_TARGET_TABLE);
}
/**
* The estimated number of affected rows, {@link Integer#MAX_VALUE}, if
* unknown.
*/
abstract int estimatedRowCount();

View File

@ -261,8 +261,12 @@ final class DeleteQueryImpl<R extends Record> extends AbstractDMLQuery<R> implem
return super.isExecutable();
}
@Override
final int estimatedRowCount() {
return Integer.MAX_VALUE;
}
}

View File

@ -105,7 +105,11 @@ final class FieldMapsForInsert extends AbstractQueryPart {
}
// Single record inserts can use the standard syntax in any dialect
else if (rows == 1 ) {
else if (rows == 1 ) {
ctx.formatSeparator()
.start(INSERT_VALUES)
.visit(K_VALUES)

View File

@ -866,13 +866,17 @@ final class InsertQueryImpl<R extends Record> extends AbstractStoreQuery<R> impl
return insertMaps.isExecutable() || defaultValues || select != null;
}
@Override
final int estimatedRowCount() {
if (defaultValues)
return 1;
else if (select != null)
return Integer.MAX_VALUE;
else
return insertMaps.rows;
}
}

View File

@ -710,8 +710,12 @@ final class UpdateQueryImpl<R extends Record> extends AbstractStoreQuery<R> impl
return updateMap.size() > 0 || multiRow != null;
}
@Override
final int estimatedRowCount() {
return Integer.MAX_VALUE;
}
}