name
stringlengths
12
178
code_snippet
stringlengths
8
36.5k
score
float64
3.26
3.68
morf_AbstractSqlDialectTest_m7_rdh
/** * Tests that an insert from a select works when no defaults are supplied. */ @Test public void m7() {SelectStatement sourceStmt = new SelectStatement(new FieldReference("id"), new FieldReference("version"), new FieldReference(STRING_FIELD), new FieldReference(INT_FIELD), new FieldReference(FLOAT_FIELD)).from(new ...
3.26
morf_AbstractSqlDialectTest_testTrim_rdh
/** * Tests that Trim functionality works. */ @Test public void testTrim() { // Given Function trim = trim(new FieldReference("field1")); SelectStatement selectStatement = new SelectStatement(trim).from(new TableReference("schedule")); // When String result = testDialect.convertStatementToSQL(selectStatement); // Th...
3.26
morf_AbstractSqlDialectTest_expectedSelectModSQL_rdh
/** * * @return The expected SQL for the MOD operator. */ protected String expectedSelectModSQL() { return "SELECT MOD(intField, 5) FROM " + tableName(TEST_TABLE); }
3.26
morf_AbstractSqlDialectTest_expectedLower_rdh
/** * * @return The expected SQL for the LOWER function. */ protected String expectedLower() { return "SELECT LOWER(field1) FROM " + tableName("schedule"); }
3.26
morf_AbstractSqlDialectTest_testMathsPlus_rdh
/** * Test that adding numbers returns as expected. */ @Test public void testMathsPlus() { String result = testDialect.getSqlFrom(new MathsField(new FieldLiteral(1), MathsOperator.PLUS, new FieldLiteral(1))); assertEquals(expectedMathsPlus(), result); }
3.26
morf_AbstractSqlDialectTest_testInsertWithNullLiterals_rdh
/** * Test that an Insert statement is generated with a null value */ @Test public void testInsertWithNullLiterals() { InsertStatement stmt = new InsertStatement().into(new TableReference(ALTERNATE_TABLE)).fields(literal(1).as("id"), literal(0).as("version"), new NullFieldLiteral().as(STRING_FIELD)); String expected...
3.26
morf_AbstractSqlDialectTest_testSelectLiteralWithWhereClause_rdh
/** * Tests SQL for selecting literal fields where is a WHERE clause */ @Test public void testSelectLiteralWithWhereClause() { assertEquals(expectedSelectLiteralWithWhereClauseString(), testDialect.convertStatementToSQL(new SelectStatement(new FieldLiteral("LITERAL")).where(eq(new FieldLit...
3.26
morf_AbstractSqlDialectTest_expectedSqlForMathOperations4_rdh
/** * * @return expected SQL for math operation 4 */ protected String expectedSqlForMathOperations4() { return "a / (b + 100)"; }
3.26
morf_AbstractSqlDialectTest_testSelectOrderByWithNoExplicitNullHandling_rdh
/** * Tests a select with an "order by" clause with nulls last and default direction. */ @Test public void testSelectOrderByWithNoExplicitNullHandling() { SelectStatement stmt = new SelectStatement(new FieldReference(STRING_FIELD)).from(new TableReference(ALTERNATE_TABLE)).orderBy(new FieldReference(STRING_FIELD).no...
3.26
morf_AbstractSqlDialectTest_expectedSqlForMathOperationsForExistingDataFix2_rdh
/** * * @param sqlForRandom * SQL to create a random number * @return expected SQL for math operation for existing data fix 2 */ protected String expectedSqlForMathOperationsForExistingDataFix2(String sqlForRandom) { return ("FLOOR(" + sqlForRandom) + " * 999999.0)"; }
3.26
morf_AbstractSqlDialectTest_testCreateViewStatementOverUnionSelect_rdh
/** * Tests the SQL for creating a view over a union select. */ @SuppressWarnings("unchecked") @Test public void testCreateViewStatementOverUnionSelect() { compareStatements(expectedCreateViewOverUnionSelectStatements(), testDialect.viewDeploymentStatements(testViewWithUnion)); }
3.26
morf_AbstractSqlDialectTest_expectedForUpdate_rdh
/** * * @return How the dialect should represent a FOR UPDATE. */ protected String expectedForUpdate() { return " FOR UPDATE"; }
3.26
morf_AbstractSqlDialectTest_testInsertIntoValuesWithComplexField_rdh
/** * Tests an INSERT INTO (...) VALUES (...) statement with a complex field. */ @Test public void testInsertIntoValuesWithComplexField() { Schema schema = schema(table("TableOne").columns(column("id", DataType.INTEGER), column("value", DataType.INTEGER))); InsertStatement testStatement = insert().into(tableRef("T...
3.26
morf_AbstractSqlDialectTest_testSelectWithSum_rdh
/** * Test the use of the sum function in a select */ @Test public void testSelectWithSum() { SelectStatement stmt = new SelectStatement(sum(new FieldReference(INT_FIELD)), sumDistinct(new FieldReference(INT_FIELD))).from(new TableReference(TEST_TABLE)); String expectedSql = "SELECT SUM(intField), SUM(DISTINCT intF...
3.26
morf_AbstractSqlDialectTest_verifyRepairAutoNumberStartPosition_rdh
/** * Verify on the expected SQL statements to be run on repairing the autonumber start position. * * @param sqlScriptExecutor * The script executor * @param connection * The connection to use */ @SuppressWarnings("unused") protected void verifyRepairAutoNumberStartPosition(SqlScriptExecutor sqlScriptExecuto...
3.26
morf_AbstractSqlDialectTest_testIsNull_rdh
/** * Test that IsNull functionality behaves as expected. */ @Test @SuppressWarnings("deprecation") public void testIsNull() { String result = testDialect.getSqlFrom(isnull(new FieldLiteral("A"), new FieldLiteral("B"))); assertEquals(expectedIsNull(), result); }
3.26
morf_AbstractSqlDialectTest_expectedAlterTableDropColumnWithDefaultStatement_rdh
/** * * @return Expected SQL for {@link #testDropColumnWithDefault()} */ protected List<String> expectedAlterTableDropColumnWithDefaultStatement() { return singletonList("ALTER TABLE Test DROP COLUMN bigIntegerField"); } /** * * @return Expected SQL for {@link #testChangeIndexFollowedByChangeOfAssociatedColumn()}
3.26
morf_AbstractSqlDialectTest_shouldGenerateCorrectSqlForMathOperationsForExistingDataFix3_rdh
/** * Regression test that checks if the DSL with Math expressions, that is used * in ReportingSchema module produces expected SQL. */ @Test public void shouldGenerateCorrectSqlForMathOperationsForExistingDataFix3() { AliasedField dsl = max(field("assetLocationDate").multiplyBy(literal(100000)).plus(field("assetLoca...
3.26
morf_AbstractSqlDialectTest_testInsertFromSelectStatementWithExplicitFieldsWhereJoinOnInnerSelect_rdh
/** * Tests an insert from a select which joins inner selects using a where clause. The fields for selection are specified. * * <p>The use case for this is to select a subset of the fields from an inner select, where the inner select has joined across several tables</p>. */ @Test public void testInsertFromSelectSta...
3.26
morf_AbstractSqlDialectTest_expectedHints2_rdh
/** * * @param rowCount * The number of rows for which to optimise the query plan. * @return The expected SQL for the {@link SelectStatement#optimiseForRowCount(int)} directive. */protected String expectedHints2(@SuppressWarnings("unused") int rowCount) { return ("SELECT a, b FROM " + tableName("Foo")) + " ORDE...
3.26
morf_AbstractSqlDialectTest_m9_rdh
/** * Test that an empty string literal is converted to {@code NULL} * on all database platforms, following the WEB-9161 harmonisation * of empty-string/null handling across vendors. * * @see #testInsertWithNullDefaults() * @see #testUpdateWithNull() */ @Test public void m9() { UpdateStatement updateStmt = new U...
3.26
morf_AbstractSqlDialectTest_testOptimiseForRowCountOnMerge_rdh
/** * Check that we don't allow the use of the optimise for row count hint with a MERGE. */ @Test(expected = IllegalArgumentException.class) public void testOptimiseForRowCountOnMerge() { testDialect.convertStatementToSQL(merge().into(tableRef("a")).from(select().from(tableRef("b")).optimiseForRowCount(2)).tableUniq...
3.26
morf_AbstractSqlDialectTest_shouldGenerateCorrectSqlForMathOperations3_rdh
/** * Test for proper SQL mathematics operation generation from DSL expressions. * <p> * Bracket should be generated for subexpression "b+c". Even without explicit * {@link org.alfasoftware.morf.sql.SqlUtils#bracket(MathsField)} call. * </p> */@Test public void shouldGenerateCorrectSqlForMathOperations3() { Strin...
3.26
morf_AbstractSqlDialectTest_shouldGenerateCorrectSqlForMathOperations15_rdh
/** * Expression that should be wrapped implicitly, is wrapped additionally with * a bracket() method. */ @Test public void shouldGenerateCorrectSqlForMathOperations15() { String result = testDialect.getSqlFrom(field("a").plus(bracket(field("b").plus(field("c")))).divideBy(literal(2))); assertEquals(expectedSqlForMa...
3.26
morf_AbstractSqlDialectTest_m16_rdh
/** * Check that we don't allow the use of the optimise for row count hint on a subquery. */ @Test(expected = IllegalArgumentException.class) public void m16() { testDialect.convertStatementToSQL(select().from(select().from("Foo").optimiseForRowCount(1)));}
3.26
morf_AbstractSqlDialectTest_testSpecifiedValueInsert_rdh
/** * Tests an insert statement where the value for each column (except the id) has been explicitly specified, */ @Test public void testSpecifiedValueInsert() { InsertStatement stmt = new InsertStatement().into(new TableReference(TEST_TABLE)).values(new FieldLiteral("Escap'd").as(STRING_FIELD), new FieldLiteral(7)....
3.26
morf_AbstractSqlDialectTest_testCastToDate_rdh
/** * Tests the output of a cast to a date. */ @Test public void testCastToDate() { String result = testDialect.getSqlFrom(new Cast(new FieldReference("value"), DataType.DATE, 10)); assertEquals(expectedDateCast(), result); }
3.26
morf_AbstractSqlDialectTest_testPostInsertWithPresetAutonumStatementsNotInsertingUnderAutonumLimit_rdh
/** * Tests the SQL statement that are run after a data insert. */ @Test public void testPostInsertWithPresetAutonumStatementsNotInsertingUnderAutonumLimit() { testDialect.postInsertWithPresetAutonumStatements(metadata.getTable(TEST_TABLE), sqlScriptExecutor, connection, false); testDialect.postInsertWithPresetAuton...
3.26
morf_AbstractSqlDialectTest_testCoalesce_rdh
/** * Test the COALESCE functionality behaves as expected */ @Test public void testCoalesce() { SelectStatement testStatement = select(coalesce(new NullFieldLiteral(), field("bob"))).from(tableRef("MyTable")); assertEquals(expectedCoalesce().toLowerCase(), testDialect.convertStatementToSQL(testStatement).toLowerCase(...
3.26
morf_AbstractSqlDialectTest_testSelectOr_rdh
/** * Tests a select with a nested "or where" clause. */ @Test public void testSelectOr() { SelectStatement stmt = new SelectStatement().from(new TableReference(TEST_TABLE)).where(or(eq(new FieldReference(STRING_FIELD), "A0001"), greaterThan(new FieldReference(INT_FIELD), 20080101))); String value = varCharCast("'A00...
3.26
morf_AbstractSqlDialectTest_testRound_rdh
/** * Test that Round functionality behaves as expected. */ @Test public void testRound() { // Given Function round = round(new FieldReference("field1"), new FieldLiteral(2)); SelectStatement stmt = new SelectStatement(round).from(new TableReference("schedule")); // When String result = testDialect.convertStatementTo...
3.26
morf_AbstractSqlDialectTest_testSelectGroupForUpdate_rdh
/** * Tests that we can't combine GROUP BY with FOR UPDATE */ @Test(expected = IllegalArgumentException.class) public void testSelectGroupForUpdate() { SelectStatement stmt = new SelectStatement().from(new TableReference(TEST_TABLE)).groupBy(field("x")).forUpdate(); testDialect.convertStatementToSQL(stmt); }
3.26
morf_AbstractSqlDialectTest_testAddBlobColumn_rdh
/** * Test adding a blob column. */ @Test public void testAddBlobColumn() { testAlterTableColumn(AlterationType.ADD, column("blobField_new", DataType.BLOB).nullable(), expectedAlterTableAddBlobColumnStatement()); }
3.26
morf_AbstractSqlDialectTest_testSelectOrderByScript_rdh
/** * Tests a select with an "order by" clause. */ @Test public void testSelectOrderByScript() { SelectStatement stmt = new SelectStatement(new FieldReference(STRING_FIELD)).from(new TableReference(ALTERNATE_TABLE)).orderBy(new FieldReference(STRING_FIELD)); String expectedSql = ("SELECT stringField FROM " + tableNam...
3.26
morf_AbstractSqlDialectTest_m12_rdh
/** * Test the GREATEST functionality behaves as expected */ @Test public void m12() { SelectStatement testStatement = select(greatest(new NullFieldLiteral(), field("bob"))).from(tableRef("MyTable")); assertEquals(expectedGreatest().toLowerCase(), testDialect.convertStatementToSQL(testStatement).toLowerCase()); }
3.26
morf_AbstractSqlDialectTest_shouldGenerateCorrectSqlForMathOperations11_rdh
/** * Test for proper SQL mathematics operation generation from DSL expressions * that use brackets. */ @Test public void shouldGenerateCorrectSqlForMathOperations11() { String result = testDialect.getSqlFrom(bracket(field("a").divideBy(literal(100)).plus(literal(1))).divideBy(field("b")).plus(literal(100))); assert...
3.26
morf_AbstractSqlDialectTest_testAlterPrimaryKeyColumnCompositeKey_rdh
/** * Test changing a column which is part of a composite primary key. */@Test public void testAlterPrimaryKeyColumnCompositeKey() { testAlterTableColumn(COMPOSITE_PRIMARY_KEY_TABLE, AlterationType.ALTER, getColumn(COMPOSITE_PRIMARY_KEY_TABLE, SECOND_PRIMARY_KEY), column(SECOND_PRIMARY_KEY, DataType.STRING, 5).primar...
3.26
morf_AbstractSqlDialectTest_expectedCreateViewStatements_rdh
/** * * @return The expected SQL statements for creating the test database view. */ protected List<String> expectedCreateViewStatements() { return Arrays.asList(((((("CREATE VIEW " + tableName("TestView")) + " AS (SELECT stringField FROM ") + tableName(TEST_TABLE)) + " WHERE (stringField = ") + stringLiteralPrefix...
3.26
morf_AbstractSqlDialectTest_testSimpleUpdate_rdh
/** * Tests that a simple update with field literal works. */ @Test public void testSimpleUpdate() { UpdateStatement stmt = new UpdateStatement(new TableReference(TEST_TABLE)).set(new FieldLiteral("A1001001").as(STRING_FIELD)); String value = varCharCast("'A1001001'"); String expectedSql = ((("UPDATE " + tableName(TE...
3.26
morf_AbstractSqlDialectTest_testSimpleDelete_rdh
/** * Tests that a simple delete string is created correctly. */ @Test public void testSimpleDelete() { DeleteStatement stmt = new DeleteStatement(new TableReference(TEST_TABLE)); String expectedSql = "DELETE FROM " + tableName(TEST_TABLE); assertEquals("Simple delete", expectedSql, testDialect.convertStatementToSQL...
3.26
morf_AbstractSqlDialectTest_testAddBooleanColumn_rdh
/** * Test adding boolean column. */ @Test public void testAddBooleanColumn() {testAlterTableColumn(AlterationType.ADD, column("booleanField_new", DataType.BOOLEAN).nullable(), expectedAlterTableAddBooleanColumnStatement()); }
3.26
morf_AbstractSqlDialectTest_expectedHints6_rdh
/** * * @return The expected SQL for the {@link SelectStatement#withParallelQueryPlan(int)} directive. */ protected String expectedHints6() { return ("SELECT a, b FROM " + tableName("Foo")) + " ORDER BY a"; }
3.26
morf_AbstractSqlDialectTest_testSelectAnd_rdh
/** * Tests a select with a nested "and where" clause. */ @Test public void testSelectAnd() { SelectStatement stmt = new SelectStatement().from(new TableReference(TEST_TABLE)).where(and(eq(new FieldReference(STRING_FIELD), "A0001"), greaterThan(new FieldReference(INT_FIELD), 20080101))); String value = varCharCast(...
3.26
morf_AbstractSqlDialectTest_shouldGenerateCorrectSqlForMathOperations7_rdh
/** * Test for proper SQL mathematics operation generation from DSL expressions * that use brackets. * <p> * Subexpression "a+b" is put to bracket explicitly, and * the subexpression "c-d" should be put to the bracket implicitly, even without explicit * {@link org.alfasoftware.morf.sql.SqlUtils#bracket(MathsField...
3.26
morf_AbstractSqlDialectTest_m23_rdh
/** * On some databases our string literals need suffixing with explicit escape * character key word. * * @return suffix to insert after quoted string literal. */ protected String m23() { return " ESCAPE '\\'"; }
3.26
morf_AbstractSqlDialectTest_testSelectFirstOrderByNullsLastDescendingScript_rdh
/** * Tests a select with an "order by" clause with nulls first and descending direction. */ @Test public void testSelectFirstOrderByNullsLastDescendingScript() { FieldReference fieldReference = new FieldReference(STRING_FIELD); SelectFirstStatement stmt = selectFirst(fieldReference).from(new TableReference(ALTERNAT...
3.26
morf_AbstractSqlDialectTest_testAlterRemoveColumnFromCompositeKey_rdh
/** * Test changing a column to remove it from a composite primary key. */ @Test public void testAlterRemoveColumnFromCompositeKey() { testAlterTableColumn(COMPOSITE_PRIMARY_KEY_TABLE, AlterationType.ALTER, getColumn(COMPOSITE_PRIMARY_KEY_TABLE, SECOND_PRIMARY_KEY), column(SECOND_PRIMARY_KEY, DataType.STRING, 5).nu...
3.26
morf_AbstractSqlDialectTest_m1_rdh
/** * Tests a select with a nested "and where" clause. */ @Test public void m1() { SelectStatement stmt = new SelectStatement().from(new TableReference(TEST_TABLE)).where(and(ImmutableList.of(eq(new FieldReference(STRING_FIELD), "A0001"), greaterThan(new FieldReference(INT_FIELD), 20080101))));String value = varCha...
3.26
morf_AbstractSqlDialectTest_expectedTrim_rdh
/** * * @return The expected SQL for a Trim */ protected String expectedTrim() { return "SELECT TRIM(field1) FROM " + tableName("schedule"); }
3.26
morf_AbstractSqlDialectTest_testInsertFromSelectWithSourceAndJoinedInDifferentSchema_rdh
/** * Tests that an insert from a select works when the source table and those in the join statement are in a different schema. */ @Test public void testInsertFromSelectWithSourceAndJoinedInDifferentSchema() { TableReference source = new TableReference("MYSCHEMA", TEST_TABLE); TableReference sourceJoin = new TableRe...
3.26
morf_AbstractSqlDialectTest_expectedUsesNVARCHARforStrings_rdh
/** * Override to set the expected NVARCHAR behaviour. * * @return whether to use NVARCHAR for strings or not */ protected boolean expectedUsesNVARCHARforStrings() { return false;}
3.26
morf_AbstractSqlDialectTest_expectedHints8a_rdh
/** * * @return The expected SQL for the {@link SelectStatement#withDialectSpecificHint(String, String)} directive. Testing all dialcts do not react to an empty hint being supplied. */ protected String expectedHints8a() { return "SELECT * FROM SCHEMA2.Foo";// NOSONAR }
3.26
morf_AbstractSqlDialectTest_testAlterColumnChangingTypeAndCase_rdh
/** * Test renaming a column, changing the case only (e.g. from columnName to ColumnName). */ @Test public void testAlterColumnChangingTypeAndCase() { testAlterTableColumn(OTHER_TABLE, AlterationType.ALTER, getColumn(OTHER_TABLE, FLOAT_FIELD), column("FloatField", DataType.DECIMAL, 20, 3), expectedAlterColumnChangi...
3.26
morf_AbstractSqlDialectTest_testPostInsertWithPresetAutonumStatementsInsertingUnderAutonumLimit_rdh
/** * Tests the SQL statement that are run after a data insert. */ @Test public void testPostInsertWithPresetAutonumStatementsInsertingUnderAutonumLimit() { testDialect.postInsertWithPresetAutonumStatements(metadata.getTable(TEST_TABLE), sqlScriptExecutor, connection, true); testDialect.postInsertWithPresetAutonumSta...
3.26
morf_AbstractSqlDialectTest_testSelectWhereInSubquery_rdh
/** * Tests a select with an IN operator against a sub-query. */ @Testpublic void testSelectWhereInSubquery() { SelectStatement inStatement = new SelectStatement(new FieldReference(STRING_FIELD)).from(new TableReference(TEST_TABLE)).where(isNotNull(new FieldReference(INT_FIELD))); SelectStatement stmt = new SelectS...
3.26
morf_AbstractSqlDialectTest_testSelectWithNestedConcatenations_rdh
/** * Tests concatenation in a select with nested concatenations. */ @Test public void testSelectWithNestedConcatenations() { SelectStatement stmt = new SelectStatement(new ConcatenatedField(new FieldReference("field1"), new ConcatenatedField(new FieldReference("field2"), new FieldLiteral("XYZ"))).as("test")).from(ne...
3.26
morf_AbstractSqlDialectTest_testTruncateTableStatements_rdh
/** * Tests SQL for clearing tables. */ @SuppressWarnings("unchecked") @Test public void testTruncateTableStatements() { Table table = metadata.getTable(TEST_TABLE); compareStatements(expectedTruncateTableStatements(), testDialect.truncateTableStatements(table)); }
3.26
morf_AbstractSqlDialectTest_expectedSqlForMathOperations2_rdh
/** * * @return expected SQL for math operation 2 */ protected String expectedSqlForMathOperations2() { return "a / b + 100"; }
3.26
morf_AbstractSqlDialectTest_expectedFloor_rdh
/** * * @return The expected SQL for the FLOOR function */ protected String expectedFloor() { return "SELECT FLOOR(floatField) FROM " + tableName(TEST_TABLE); }
3.26
morf_AbstractSqlDialectTest_testYYYYMMDDToDate_rdh
/** * Test that YYYYMMDDToDate functionality behaves as expected. */ @Test public void testYYYYMMDDToDate() { String result = testDialect.getSqlFrom(yyyymmddToDate(new FieldLiteral("20100101"))); assertEquals(expectedYYYYMMDDToDate(), result); }
3.26
morf_AbstractSqlDialectTest_testParameterisedInsertWithTableInDifferentSchema_rdh
/** * Same as {@link #testParameterisedInsert()}, but this also checks when the table is in a separate schema. */ @Test public void testParameterisedInsertWithTableInDifferentSchema() { AliasedField[] fields = new AliasedField[]{ new FieldLiteral(5).as("id"), new FieldLiteral("Escap'd").as(STRING_FIELD), new FieldLi...
3.26
morf_AbstractSqlDialectTest_expectedHints4a_rdh
/** * * @return The expected SQL for the {@link InsertStatement#avoidDirectPath()} directive. */ protected String expectedHints4a() { return (("INSERT INTO " + tableName("Foo")) + " SELECT a, b FROM ") + tableName("Foo_1"); }
3.26
morf_AbstractSqlDialectTest_testMergeWhenAllFieldsInPrimaryKey_rdh
/** * Ensure that we can merge into a table where all columns are in the primary key. */ @Test public void testMergeWhenAllFieldsInPrimaryKey() { TableReference foo = new TableReference("foo").as("foo"); TableReference somewhere = new TableReference("somewhere"); SelectStatement sourceStmt = new SelectStatement(som...
3.26
morf_AbstractSqlDialectTest_testDeleteWithLimitAndSimpleWhereCriterion_rdh
/** * Tests that a delete string with a limit and a simple where criterion is created correctly. */ @Test public void testDeleteWithLimitAndSimpleWhereCriterion() { DeleteStatement stmt = DeleteStatement.delete(new TableReference(TEST_TABLE)).where(eq(new FieldReference(new TableReference(TEST_TABLE), STRING_FIELD), ...
3.26
morf_AbstractSqlDialectTest_testAlterStringColumn_rdh
/** * Test altering a string column. */ @Test public void testAlterStringColumn() { testAlterTableColumn(TEST_TABLE, AlterationType.ALTER, getColumn(TEST_TABLE, STRING_FIELD), column(STRING_FIELD, DataType.STRING, 6).nullable(), expectedAlterTableAlterStringColumnStatement()); }
3.26
morf_AbstractSqlDialectTest_expectedSelectOrderByTwoFields_rdh
/** * * @return Expected SQL for {@link #testSelectOrderByTwoFields()} */protected String expectedSelectOrderByTwoFields() { return ("SELECT stringField1, stringField2 FROM " + tableName(ALTERNATE_TABLE)) + " ORDER BY stringField1 DESC NULLS FIRST, stringField2 NULLS LAST"; }
3.26
morf_AbstractSqlDialectTest_setMaxIdOnAutonumberTable_rdh
/** * Method to override in dialect specific tests to set the max id value on the autonumber table for use during * testRepairAutoNumberStartPosition * * @param id * The max id */ protected void setMaxIdOnAutonumberTable(@SuppressWarnings("unused")long id) { }
3.26
morf_AbstractSqlDialectTest_testSelectWithRowNumberFunction_rdh
/** * Test the row number function in a select. */ @Test public void testSelectWithRowNumberFunction() {SelectStatement stmt = new SelectStatement(new FieldReference(STRING_FIELD), rowNumber()).from(new TableReference(ALTERNATE_TABLE)).groupBy(new FieldReference(STRING_FIELD)); String expectedSql = ((("SELECT stri...
3.26
morf_AbstractSqlDialectTest_m5_rdh
/** * * @return the decimal representation of a literal for testing */ protected String m5() { return "SELECT MIN(intField - 1) FROM " + tableName(TEST_TABLE); }
3.26
morf_AbstractSqlDialectTest_expectedSelectEvery_rdh
/** * * @return The expected sql. */ protected String expectedSelectEvery() { return "SELECT MIN(booleanField) FROM " + tableName(TEST_TABLE); }
3.26
morf_AbstractSqlDialectTest_testAddStringColumn_rdh
/** * Test adding a string column. */ @Test public void testAddStringColumn() { testAlterTableColumn(AlterationType.ADD, column("stringField_new", DataType.STRING, 6).nullable(), expectedAlterTableAddStringColumnStatement()); }
3.26
morf_AbstractSqlDialectTest_testSelectWithTableAlias_rdh
/** * Tests a select with table aliases. */ @Test public void testSelectWithTableAlias() {SelectStatement stmt = new SelectStatement(new FieldReference(STRING_FIELD), new FieldReference(INT_FIELD), new FieldReference(DATE_FIELD).as("aliasDate")).from(new TableReference(TEST_TABLE).as("aliasTest"));String expectedSql ...
3.26
morf_AbstractSqlDialectTest_testDialectHasNoBespokeTests_rdh
/** * Test that ensures that no dialect specific tests exist. I.e. If there is an SQL dialect test * then it must be defined here so that all descendent dialects are obliged to support it. * * <p>This test exists to make sure we test all required SQL constructs on all supported platforms. * Previously there were l...
3.26
morf_AbstractSqlDialectTest_expectedRandomFunction_rdh
/** * * @return The expected random function sql. */ protected String expectedRandomFunction() { return "RAND()"; }
3.26
morf_AbstractSqlDialectTest_testRepairAutoNumberStartPositionUnderRepairLimit_rdh
/** * Tests for {@link SqlDialect#repairAutoNumberStartPosition(Table, SqlScriptExecutor, Connection)} */ @Testpublic void testRepairAutoNumberStartPositionUnderRepairLimit() { setMaxIdOnAutonumberTable(MAX_ID_UNDER_REPAIR_LIMIT); testDialect.repairAutoNumberStartPosition(metadata.getTable(TEST_TABLE), sqlScriptExecu...
3.26
morf_AbstractSqlDialectTest_m33_rdh
/** * * @return The expected SQL for the {@link InsertStatement#useParallelDml()} ()} directive. */ protected String m33() { return (("INSERT INTO " + tableName("Foo")) + " SELECT a, b FROM ") + tableName("Foo_1"); }
3.26
morf_AbstractSqlDialectTest_expectedSqlForMathOperations6_rdh
/** * * @return expected SQL for math operation 6 */ protected String expectedSqlForMathOperations6() { return "a + b / (c - d)"; }
3.26
morf_AbstractSqlDialectTest_testSelectDistinctForUpdate_rdh
/** * Tests that we can't combine DISTINCT with FOR UPDATE */ @Test(expected = IllegalArgumentException.class) public void testSelectDistinctForUpdate() { SelectStatement stmt = selectDistinct().from(new TableReference(TEST_TABLE)).forUpdate(); testDialect.convertStatementToSQL(stmt); }
3.26
morf_AbstractSqlDialectTest_expectedSqlForMathOperations12_rdh
/** * * @return expected SQL for math operation 12 */ protected String expectedSqlForMathOperations12() { return "(a + b) / c"; }
3.26
morf_AbstractSqlDialectTest_m0_rdh
/** * Tests SQL for dropping a table. */ @SuppressWarnings("unchecked") @Test public void m0() { Table table = metadata.getTable(TEST_TABLE); compareStatements(expectedDropTableStatements(), testDialect.dropStatements(table)); }
3.26
morf_AbstractSqlDialectTest_testSelectOrList_rdh
/** * Tests a select with a nested "or where" clause. */ @Test public void testSelectOrList() { SelectStatement stmt = new SelectStatement().from(new TableReference(TEST_TABLE)).where(or(ImmutableList.of(eq(new FieldReference(STRING_FIELD), "A0001"), greaterThan(new FieldReference(INT_FIELD), 20080101)))); String val...
3.26
morf_AbstractSqlDialectTest_testSelectWhereIsNotNull_rdh
/** * Tests a select with a not null check clause. */ @Test public void testSelectWhereIsNotNull() { SelectStatement stmt = new SelectStatement().from(new TableReference(TEST_TABLE)).where(isNotNull(new FieldReference(INT_FIELD)));String expectedSql = ("SELECT * FROM " + tableName(TEST_TABLE)) + " WHERE (intField IS...
3.26
morf_AbstractSqlDialectTest_testSelectWithExceptStatementsWithDbLinkLatter_rdh
/** * Tests the generation of SQL string for a query with EXCEPT operator where a * latter select uses DB-link. */ @Test public void testSelectWithExceptStatementsWithDbLinkLatter() { assumeTrue("for dialects with no EXCEPT operation support the test will be skipped.", expectedSelectWithExceptAndDbLinkLatter() != n...
3.26
morf_AbstractSqlDialectTest_testSelectSumWithExpression_rdh
/** * Tests select statement with SUM function using more than a simple field. */ @Test public void testSelectSumWithExpression() { SelectStatement stmt = select(sum(field(INT_FIELD).multiplyBy(literal(2)).divideBy(literal(3)))).from(tableRef(TEST_TABLE)); assertEquals("Select scripts are not the same", expectedSele...
3.26
morf_AbstractSqlDialectTest_testInsertWithNonNullDefault_rdh
/** * Test that an insert is generated with a single space as the default * value for a character field. */ @Test public void testInsertWithNonNullDefault() { InsertStatement stmt = new InsertStatement().into(new TableReference(TEST_TABLE)).from(new TableReference(OTHER_TABLE)).withDefaults(new NullFieldLiteral().as...
3.26
morf_AbstractSqlDialectTest_assertSQLEquals_rdh
/** * Helper to allow lists of SQL strings to be compared in Eclipse. * * @param message * The message to show on failure. * @param expected * The expected list of strings. * @param actual * The actual list of strings. */ private void assertSQLEquals(String message, List<String> expected, List<String> ac...
3.26
morf_AbstractSqlDialectTest_testUpdateUsingSourceTableInDifferentSchema_rdh
/** * Tests an update where the source table is in a different schema. */ @Test public void testUpdateUsingSourceTableInDifferentSchema() { SelectStatement selectStmt = new SelectStatement(new FieldReference("settlementFrequency")).from(new TableReference("MYSCHEMA", "FloatingRateDetail").as("B")).where(eq(new FieldR...
3.26
morf_AbstractSqlDialectTest_testSelectHavingScript_rdh
/** * Tests a select with a "having" clause. */ @Test public void testSelectHavingScript() { SelectStatement stmt = new SelectStatement(new FieldReference(STRING_FIELD)).from(new TableReference(ALTERNATE_TABLE)).groupBy(new FieldReference(STRING_FIELD)).having(eq(new FieldReference("blah"), "X")); String value = va...
3.26
morf_AbstractSqlDialectTest_testUpdateUsingTargetTableInDifferentSchema_rdh
/** * Tests an update where the destination table is in a different schema. */ @Test public void testUpdateUsingTargetTableInDifferentSchema() { SelectStatement selectStmt = new SelectStatement(new FieldReference("settlementFrequency")).from(new TableReference("FloatingRateDetail").as("B")).where(eq(new FieldReferenc...
3.26
morf_AbstractSqlDialectTest_expectedBooleanLiteral_rdh
/** * * @param value * the boolean value to translate. * @return The expected boolean literal. */ protected String expectedBooleanLiteral(boolean value) { return value ? "1" : "0"; }
3.26
morf_AbstractSqlDialectTest_testSelectForUpdate_rdh
/** * Tests the SQL for select for update */ @Test public void testSelectForUpdate() { SelectStatement stmt = new SelectStatement().from(new TableReference(TEST_TABLE)).forUpdate(); assertEquals("SQL to select for update", ("SELECT * FROM " + tableName(TEST_TABLE)) + expectedForUpdate(), testDialect.conve...
3.26
morf_AbstractSqlDialectTest_testSelectWithWhereLessThanOrEqualTo_rdh
/** * Tests a select with a simple where clause. */ @Test public void testSelectWithWhereLessThanOrEqualTo() { SelectStatement stmt = new SelectStatement().from(new TableReference(TEST_TABLE)).where(lessThanOrEqualTo(new FieldReference(INT_FIELD), 20090101)); String expectedSql = ("SELECT * FROM " + tableName(TEST_...
3.26
morf_AbstractSqlDialectTest_testSubstring_rdh
/** * Tests that substringing functionality works. */ @Test public void testSubstring() { // Given Function substring = substring(new FieldReference("field1"), new FieldLiteral(1), new FieldLiteral(3)); SelectStatement stmt = new SelectStatement(substring).from(new TableReference("schedule")); // When String result ...
3.26
morf_AbstractSqlDialectTest_m36_rdh
/** * Tests formatting of binary values in record derived from a {@link ResultSet}. * * @throws SQLException * when a database access error occurs */ @Test public void m36() throws SQLException { assertEquals("Value not transformed into Base64", "REVG", checkDatabaseByteArrayToRecordValue(new byte[]{ 68, 69, 70 ...
3.26
morf_AbstractSqlDialectTest_testSelectWithLikeClause_rdh
/** * Tests a select with a where like clause. */ @Test public void testSelectWithLikeClause() { SelectStatement v98 = new SelectStatement().from(new TableReference(TEST_TABLE)).where(like(new FieldReference(STRING_FIELD), "A%")); String value = varCharCast("'A%'"); String expectedSql = ((((("SELECT * FROM " + tabl...
3.26
morf_AbstractSqlDialectTest_expectedSqlForMathOperations3_rdh
/** * * @return expected SQL for math operation 3 */ protected String expectedSqlForMathOperations3() {return "a / (b + c)"; }
3.26
morf_AbstractSqlDialectTest_testSelectWhereInSubqueryWithAllFields_rdh
/** * Tests if a select with an IN operator and a sub-select containing all (*) * fields from sub-table throws an exception. */ @Testpublic void testSelectWhereInSubqueryWithAllFields() { SelectStatement inStatement = new SelectStatement().from(new TableReference(TEST_TABLE)).where(isNotNull(new FieldReference(INT_F...
3.26
morf_AbstractSqlDialectTest_testAlterPrimaryKeyColumn_rdh
/** * Test changing a column which is the primary key. */ @Test public void testAlterPrimaryKeyColumn() { testAlterTableColumn(TEST_TABLE, AlterationType.ALTER, getColumn(TEST_TABLE, "id"), column("renamedId", DataType.BIG_INTEGER).primaryKey(), expectedAlterPrimaryKeyColumnStatements()); }
3.26
morf_AbstractSqlDialectTest_testCastFunctionToBigInt_rdh
/** * Tests the output of a cast of a function to a big int. */ @Test public void testCastFunctionToBigInt() { String result = testDialect.getSqlFrom(new Cast(min(field("value")), DataType.BIG_INTEGER, 10)); assertEquals(expectedBigIntFunctionCast(), result); }
3.26
morf_AbstractSqlDialectTest_testInsertFromSelectWithMismatchedFieldsError_rdh
/** * Tests that an insert from a select with mis matched fields generates an error. */ @Test public void testInsertFromSelectWithMismatchedFieldsError() { SelectStatement sourceStmt = new SelectStatement(new FieldReference("id"), new FieldReference("version"), new FieldReference(STRING_FIELD)).from(new TableReferen...
3.26