Search in sources :

Example 96 with MockConfig

use of org.seasar.doma.internal.jdbc.mock.MockConfig in project doma by domaframework.

the class MssqlPagingTransformerTest method testOffsetLimit.

@Test
public void testOffsetLimit() {
    String expected = "select emp.id from emp order by emp.id offset 5 rows fetch next 10 rows only";
    MssqlPagingTransformer transformer = new MssqlPagingTransformer(5, 10, false);
    SqlParser parser = new SqlParser("select emp.id from emp order by emp.id");
    SqlNode sqlNode = transformer.transform(parser.parse());
    NodePreparedSqlBuilder sqlBuilder = new NodePreparedSqlBuilder(new MockConfig(), SqlKind.SELECT, "dummyPath");
    PreparedSql sql = sqlBuilder.build(sqlNode, Function.identity());
    assertEquals(expected, sql.getRawSql());
}
Also used : PreparedSql(org.seasar.doma.jdbc.PreparedSql) SqlParser(org.seasar.doma.internal.jdbc.sql.SqlParser) NodePreparedSqlBuilder(org.seasar.doma.internal.jdbc.sql.NodePreparedSqlBuilder) MockConfig(org.seasar.doma.internal.jdbc.mock.MockConfig) SqlNode(org.seasar.doma.jdbc.SqlNode) Test(org.junit.jupiter.api.Test)

Example 97 with MockConfig

use of org.seasar.doma.internal.jdbc.mock.MockConfig in project doma by domaframework.

the class MssqlPagingTransformerTest method testLimitOnly_option_forceOffsetFetch.

@Test
public void testLimitOnly_option_forceOffsetFetch() {
    String expected = "select emp.id from emp order by emp.id  offset 0 rows fetch next 10 rows only option (maxrecursion 0)";
    MssqlPagingTransformer transformer = new MssqlPagingTransformer(-1, 10, true);
    SqlParser parser = new SqlParser("select emp.id from emp order by emp.id option (maxrecursion 0)");
    SqlNode sqlNode = transformer.transform(parser.parse());
    NodePreparedSqlBuilder sqlBuilder = new NodePreparedSqlBuilder(new MockConfig(), SqlKind.SELECT, "dummyPath");
    PreparedSql sql = sqlBuilder.build(sqlNode, Function.identity());
    assertEquals(expected, sql.getRawSql());
}
Also used : PreparedSql(org.seasar.doma.jdbc.PreparedSql) SqlParser(org.seasar.doma.internal.jdbc.sql.SqlParser) NodePreparedSqlBuilder(org.seasar.doma.internal.jdbc.sql.NodePreparedSqlBuilder) MockConfig(org.seasar.doma.internal.jdbc.mock.MockConfig) SqlNode(org.seasar.doma.jdbc.SqlNode) Test(org.junit.jupiter.api.Test)

Example 98 with MockConfig

use of org.seasar.doma.internal.jdbc.mock.MockConfig in project doma by domaframework.

the class MssqlPagingTransformerTest method testOffsetOnly.

@Test
public void testOffsetOnly() {
    String expected = "select emp.id from emp order by emp.id offset 5 rows";
    MssqlPagingTransformer transformer = new MssqlPagingTransformer(5, -1, false);
    SqlParser parser = new SqlParser("select emp.id from emp order by emp.id");
    SqlNode sqlNode = transformer.transform(parser.parse());
    NodePreparedSqlBuilder sqlBuilder = new NodePreparedSqlBuilder(new MockConfig(), SqlKind.SELECT, "dummyPath");
    PreparedSql sql = sqlBuilder.build(sqlNode, Function.identity());
    assertEquals(expected, sql.getRawSql());
}
Also used : PreparedSql(org.seasar.doma.jdbc.PreparedSql) SqlParser(org.seasar.doma.internal.jdbc.sql.SqlParser) NodePreparedSqlBuilder(org.seasar.doma.internal.jdbc.sql.NodePreparedSqlBuilder) MockConfig(org.seasar.doma.internal.jdbc.mock.MockConfig) SqlNode(org.seasar.doma.jdbc.SqlNode) Test(org.junit.jupiter.api.Test)

Example 99 with MockConfig

use of org.seasar.doma.internal.jdbc.mock.MockConfig in project doma by domaframework.

the class MssqlPagingTransformerTest method testLimitOnly_forceOffsetFetch.

@Test
public void testLimitOnly_forceOffsetFetch() {
    String expected = "select emp.id from emp order by emp.id offset 0 rows fetch next 10 rows only";
    MssqlPagingTransformer transformer = new MssqlPagingTransformer(-1, 10, true);
    SqlParser parser = new SqlParser("select emp.id from emp order by emp.id");
    SqlNode sqlNode = transformer.transform(parser.parse());
    NodePreparedSqlBuilder sqlBuilder = new NodePreparedSqlBuilder(new MockConfig(), SqlKind.SELECT, "dummyPath");
    PreparedSql sql = sqlBuilder.build(sqlNode, Function.identity());
    assertEquals(expected, sql.getRawSql());
}
Also used : PreparedSql(org.seasar.doma.jdbc.PreparedSql) SqlParser(org.seasar.doma.internal.jdbc.sql.SqlParser) NodePreparedSqlBuilder(org.seasar.doma.internal.jdbc.sql.NodePreparedSqlBuilder) MockConfig(org.seasar.doma.internal.jdbc.mock.MockConfig) SqlNode(org.seasar.doma.jdbc.SqlNode) Test(org.junit.jupiter.api.Test)

Example 100 with MockConfig

use of org.seasar.doma.internal.jdbc.mock.MockConfig in project doma by domaframework.

the class MssqlPagingTransformerTest method testOffsetOnly_forceOffsetFetch.

@Test
public void testOffsetOnly_forceOffsetFetch() {
    String expected = "select emp.id from emp order by emp.id offset 5 rows";
    MssqlPagingTransformer transformer = new MssqlPagingTransformer(5, -1, true);
    SqlParser parser = new SqlParser("select emp.id from emp order by emp.id");
    SqlNode sqlNode = transformer.transform(parser.parse());
    NodePreparedSqlBuilder sqlBuilder = new NodePreparedSqlBuilder(new MockConfig(), SqlKind.SELECT, "dummyPath");
    PreparedSql sql = sqlBuilder.build(sqlNode, Function.identity());
    assertEquals(expected, sql.getRawSql());
}
Also used : PreparedSql(org.seasar.doma.jdbc.PreparedSql) SqlParser(org.seasar.doma.internal.jdbc.sql.SqlParser) NodePreparedSqlBuilder(org.seasar.doma.internal.jdbc.sql.NodePreparedSqlBuilder) MockConfig(org.seasar.doma.internal.jdbc.mock.MockConfig) SqlNode(org.seasar.doma.jdbc.SqlNode) Test(org.junit.jupiter.api.Test)

Aggregations

MockConfig (org.seasar.doma.internal.jdbc.mock.MockConfig)144 Test (org.junit.jupiter.api.Test)140 NodePreparedSqlBuilder (org.seasar.doma.internal.jdbc.sql.NodePreparedSqlBuilder)64 SqlParser (org.seasar.doma.internal.jdbc.sql.SqlParser)64 PreparedSql (org.seasar.doma.jdbc.PreparedSql)59 SqlNode (org.seasar.doma.jdbc.SqlNode)59 PostgresDialect (org.seasar.doma.jdbc.dialect.PostgresDialect)12 Emp_ (org.seasar.doma.jdbc.criteria.entity.Emp_)11 ArrayList (java.util.ArrayList)9 LinkedHashMap (java.util.LinkedHashMap)9 NoIdEmp_ (org.seasar.doma.jdbc.criteria.entity.NoIdEmp_)9 Mssql2008Dialect (org.seasar.doma.jdbc.dialect.Mssql2008Dialect)9 MssqlDialect (org.seasar.doma.jdbc.dialect.MssqlDialect)9 BigDecimal (java.math.BigDecimal)8 Db2Dialect (org.seasar.doma.jdbc.dialect.Db2Dialect)8 Dialect (org.seasar.doma.jdbc.dialect.Dialect)8 OracleDialect (org.seasar.doma.jdbc.dialect.OracleDialect)8 MockResultSet (org.seasar.doma.internal.jdbc.mock.MockResultSet)6 RowData (org.seasar.doma.internal.jdbc.mock.RowData)6 Emp (example.entity.Emp)5