mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
#2908 - [Oracle] Change OraclePlatform to use AnsiSqlLimiter (noting Oracle does not support FOR UPDATE with FETCH/OFFSET
This commit is contained in:
@@ -5,6 +5,7 @@ import io.ebean.xtest.BaseTestCase;
|
||||
import io.ebean.xtest.ForPlatform;
|
||||
import io.ebean.annotation.Platform;
|
||||
import io.ebean.test.LoggedSql;
|
||||
import io.ebean.xtest.IgnorePlatform;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.tests.model.basic.Customer;
|
||||
import org.tests.model.basic.EBasic;
|
||||
@@ -39,7 +40,7 @@ public class TestQueryForUpdate extends BaseTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
// @IgnorePlatform(Platform.ORACLE)
|
||||
@IgnorePlatform(Platform.ORACLE)
|
||||
@Test
|
||||
public void testForUpdate_withLimit() {
|
||||
ResetBasicData.reset();
|
||||
|
||||
@@ -3,8 +3,10 @@ package org.tests.query;
|
||||
import io.ebean.DB;
|
||||
import io.ebean.PagedList;
|
||||
import io.ebean.Transaction;
|
||||
import io.ebean.annotation.Platform;
|
||||
import io.ebean.test.LoggedSql;
|
||||
import io.ebean.xtest.BaseTestCase;
|
||||
import io.ebean.xtest.IgnorePlatform;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.tests.model.basic.Customer;
|
||||
import org.tests.model.basic.Order;
|
||||
@@ -267,7 +269,7 @@ public class TestQueryFindPagedList extends BaseTestCase {
|
||||
assertThat(trimSql(loggedSql.get(1), 3)).contains(" b.id, b.status, b.order_date");
|
||||
}
|
||||
|
||||
// @IgnorePlatform(Platform.ORACLE)
|
||||
@IgnorePlatform(Platform.ORACLE)
|
||||
@Test
|
||||
void test_forUpdate() {
|
||||
ResetBasicData.reset();
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
package io.ebean.platform.oracle;
|
||||
|
||||
import io.ebean.config.dbplatform.SqlLimitRequest;
|
||||
import io.ebean.config.dbplatform.SqlLimitResponse;
|
||||
import io.ebean.config.dbplatform.SqlLimiter;
|
||||
|
||||
/**
|
||||
* Use ANSI offset rows syntax.
|
||||
*/
|
||||
final class OracleAnsiSqlRowsLimiter implements SqlLimiter {
|
||||
|
||||
@Override
|
||||
public SqlLimitResponse limit(SqlLimitRequest request) {
|
||||
String dbSql = request.getDbSql();
|
||||
StringBuilder sb = new StringBuilder(50 + dbSql.length());
|
||||
sb.append("select ");
|
||||
if (request.isDistinct()) {
|
||||
sb.append("distinct ");
|
||||
}
|
||||
sb.append(dbSql);
|
||||
int firstRow = request.getFirstRow();
|
||||
if (firstRow > 0) {
|
||||
sb.append(" offset ").append(firstRow).append(" rows");
|
||||
}
|
||||
int maxRows = request.getMaxRows();
|
||||
if (maxRows > 0) {
|
||||
sb.append(" fetch next ").append(maxRows).append(" rows only");
|
||||
}
|
||||
// Oracle does not support FOR UPDATE clause with limit offset
|
||||
return new SqlLimitResponse(sb.toString());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,13 +3,7 @@ package io.ebean.platform.oracle;
|
||||
import io.ebean.BackgroundExecutor;
|
||||
import io.ebean.Query;
|
||||
import io.ebean.annotation.Platform;
|
||||
import io.ebean.config.dbplatform.BasicSqlAnsiLimiter;
|
||||
import io.ebean.config.dbplatform.DatabasePlatform;
|
||||
import io.ebean.config.dbplatform.DbPlatformType;
|
||||
import io.ebean.config.dbplatform.DbType;
|
||||
import io.ebean.config.dbplatform.IdType;
|
||||
import io.ebean.config.dbplatform.PlatformIdGenerator;
|
||||
import io.ebean.config.dbplatform.SqlErrorCodes;
|
||||
import io.ebean.config.dbplatform.*;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.sql.Types;
|
||||
@@ -27,7 +21,7 @@ public class OraclePlatform extends DatabasePlatform {
|
||||
this.maxTableNameLength = 30;
|
||||
this.maxConstraintNameLength = 30;
|
||||
this.dbEncrypt = new OracleDbEncrypt();
|
||||
this.sqlLimiter = new OracleAnsiSqlRowsLimiter();
|
||||
this.sqlLimiter = new AnsiSqlRowsLimiter();
|
||||
this.basicSqlLimiter = new BasicSqlAnsiLimiter();
|
||||
this.historySupport = new OracleDbHistorySupport();
|
||||
this.truncateTable = "truncate table %s cascade";
|
||||
|
||||
Reference in New Issue
Block a user