Examples of MutableColumn


Examples of org.apache.metamodel.schema.MutableColumn

        assertEquals("SELECT Col1 WHERE YEAR(Col1) = 2008", new Query().select(col1).where("YEAR(Col1) = 2008")
                .toString());
    }

    public void testToSqlWhereItem() throws Exception {
        MutableColumn col1 = new MutableColumn("Col1", ColumnType.VARCHAR);
        SelectItem selectItem = new SelectItem(col1);
        FilterItem c = new FilterItem(selectItem, OperatorType.DIFFERENT_FROM, null);
        assertEquals("Col1 IS NOT NULL", c.toString());

        try {
            c = new FilterItem(selectItem, OperatorType.GREATER_THAN, null);
            fail("Exception should have been thrown");
        } catch (IllegalArgumentException e) {
            assertEquals("Can only use EQUALS or DIFFERENT_FROM operator with null-operand", e.getMessage());
        }

        c = new FilterItem(selectItem, OperatorType.DIFFERENT_FROM, "foo");
        assertEquals("Col1 <> 'foo'", c.toString());

        c = new FilterItem(selectItem, OperatorType.DIFFERENT_FROM, "'bar'");

        // this will be rewritten so it's not an issue even though it look like
        // it needs an escape-char
        assertEquals("Col1 <> ''bar''", c.toSql());

        c = new FilterItem(selectItem, OperatorType.DIFFERENT_FROM, "foo's bar");
        // the same applies here
        assertEquals("Col1 <> 'foo's bar'", c.toSql());

        col1.setType(ColumnType.FLOAT);
        c = new FilterItem(selectItem, OperatorType.EQUALS_TO, 423);
        assertEquals("Col1 = 423", c.toString());

        c = new FilterItem(selectItem, OperatorType.EQUALS_TO, 423426235423.42);
        assertEquals("Col1 = 423426235423.42", c.toString());

        c = new FilterItem(selectItem, OperatorType.EQUALS_TO, true);
        assertEquals("Col1 = 1", c.toString());

        Column timeColumn = new MutableColumn("TimeCol", ColumnType.TIME);
        selectItem = new SelectItem(timeColumn);
        c = new FilterItem(selectItem, OperatorType.GREATER_THAN, "02:30:05.000");
        assertEquals("TimeCol > TIME '02:30:05'", c.toString());

        Column dateColumn = new MutableColumn("DateCol", ColumnType.DATE);
        c = new FilterItem(new SelectItem(dateColumn), OperatorType.GREATER_THAN, "2000-12-31");
        assertEquals("DateCol > DATE '2000-12-31'", c.toString());
    }
View Full Code Here

Examples of org.apache.metamodel.schema.MutableColumn

        c = new FilterItem(new SelectItem(dateColumn), OperatorType.GREATER_THAN, "2000-12-31");
        assertEquals("DateCol > DATE '2000-12-31'", c.toString());
    }

    public void testToStringTimeStamp() throws Exception {
        Column timestampColumn = new MutableColumn("TimestampCol", ColumnType.TIMESTAMP);
        FilterItem c = new FilterItem(new SelectItem(timestampColumn), OperatorType.LESS_THAN,
                "2000-12-31 02:30:05.007");
        assertEquals("TimestampCol < TIMESTAMP '2000-12-31 02:30:05'", c.toString());

        c = new FilterItem(new SelectItem(timestampColumn), OperatorType.LESS_THAN, "2000-12-31 02:30:05");
        assertEquals("TimestampCol < TIMESTAMP '2000-12-31 02:30:05'", c.toString());

        Column dateColumn = new MutableColumn("DateCol", ColumnType.DATE);
        c = new FilterItem(new SelectItem(timestampColumn), OperatorType.GREATER_THAN, new SelectItem(dateColumn));
        assertEquals("TimestampCol > DateCol", c.toString());
    }
View Full Code Here

Examples of org.apache.metamodel.schema.MutableColumn

        c = new FilterItem(new SelectItem(timestampColumn), OperatorType.GREATER_THAN, new SelectItem(dateColumn));
        assertEquals("TimestampCol > DateCol", c.toString());
    }

    public void testEvaluateStrings() throws Exception {
        Column col1 = new MutableColumn("Col1", ColumnType.VARCHAR);
        Column col2 = new MutableColumn("Col2", ColumnType.VARCHAR);
        SelectItem s1 = new SelectItem(col1);
        SelectItem s2 = new SelectItem(col2);
        SelectItem[] selectItems = new SelectItem[] { s1, s2 };
        SimpleDataSetHeader header = new SimpleDataSetHeader(selectItems);
        Row row;
View Full Code Here

Examples of org.apache.metamodel.schema.MutableColumn

        row = new DefaultRow(header, new Object[] { "foobbdbafsdfr", "fo%b%r" });
        assertTrue(c.evaluate(row));
    }

    public void testEvaluateNull() throws Exception {
        Column col1 = new MutableColumn("Col1", ColumnType.INTEGER);
        Column col2 = new MutableColumn("Col2", ColumnType.DECIMAL);
        SelectItem s1 = new SelectItem(col1);
        SelectItem s2 = new SelectItem(col2);
        SelectItem[] selectItems = new SelectItem[] { s1, s2 };
        CachingDataSetHeader header = new CachingDataSetHeader(selectItems);
View Full Code Here

Examples of org.apache.metamodel.schema.MutableColumn

        row = new DefaultRow(header, new Object[] { null, null });
        assertTrue(c.evaluate(row));
    }

    public void testEvaluateDates() throws Exception {
        Column col1 = new MutableColumn("Col1", ColumnType.DATE);
        SelectItem s1 = new SelectItem(col1);
        SelectItem[] selectItems = new SelectItem[] { s1 };
        CachingDataSetHeader header = new CachingDataSetHeader(selectItems);

        long currentTimeMillis = System.currentTimeMillis();
View Full Code Here

Examples of org.apache.metamodel.schema.MutableColumn

        row = new DefaultRow(header, new Object[] { new java.sql.Date(currentTimeMillis - 10000000) });
        assertTrue(c.evaluate(row));
    }

    public void testEvaluateBooleans() throws Exception {
        Column col1 = new MutableColumn("Col1", ColumnType.BIT);
        SelectItem s1 = new SelectItem(col1);
        SelectItem[] selectItems = new SelectItem[] { s1 };
        DataSetHeader header = new SimpleDataSetHeader(selectItems);

        FilterItem c = new FilterItem(s1, OperatorType.EQUALS_TO, true);
View Full Code Here

Examples of org.apache.metamodel.schema.MutableColumn

     * <li>the hashcode is the same when run twice on an unaltered object</li>
     * <li>if o1.equals(o2) then this condition must be true: o1.hashCode() ==
     * 02.hashCode()
     */
    public void testEqualsAndHashCode() throws Exception {
        Column col1 = new MutableColumn("Col1", ColumnType.BIT);

        FilterItem c1 = new FilterItem(new SelectItem(col1), OperatorType.EQUALS_TO, true);
        FilterItem c2 = new FilterItem(new SelectItem(col1), OperatorType.EQUALS_TO, true);
        assertEquals(c1, c2);
        assertEquals(c1.hashCode(), c2.hashCode());

        c2 = new FilterItem(new SelectItem(col1), OperatorType.GREATER_THAN, true);
        assertFalse(c1.equals(c2));
        assertFalse(c1.hashCode() == c2.hashCode());

        Column col2 = new MutableColumn("Col2", ColumnType.VARBINARY);
        c2 = new FilterItem(new SelectItem(col2), OperatorType.EQUALS_TO, true);
        assertFalse(c1.equals(c2));
        assertFalse(c1.hashCode() == c2.hashCode());
    }
View Full Code Here

Examples of org.apache.metamodel.schema.MutableColumn

        assertFalse(c1.equals(c2));
        assertFalse(c1.hashCode() == c2.hashCode());
    }

    public void testOrFilterItem() throws Exception {
        Column col1 = new MutableColumn("Col1", ColumnType.VARCHAR);

        SelectItem s1 = new SelectItem(col1);
        FilterItem c1 = new FilterItem(s1, OperatorType.EQUALS_TO, "foo");
        FilterItem c2 = new FilterItem(s1, OperatorType.EQUALS_TO, "bar");
        FilterItem c3 = new FilterItem(s1, OperatorType.EQUALS_TO, "foobar");
View Full Code Here

Examples of org.apache.metamodel.schema.MutableColumn

        assertFalse(filter.evaluate(new DefaultRow(header, new Object[] { "foob" })));
    }

    public void testAndFilterItem() throws Exception {
        Column col1 = new MutableColumn("Col1", ColumnType.VARCHAR);

        SelectItem s1 = new SelectItem(col1);
        FilterItem c1 = new FilterItem(s1, OperatorType.LIKE, "foo%");
        FilterItem c2 = new FilterItem(s1, OperatorType.LIKE, "%bar");
        FilterItem c3 = new FilterItem(s1, OperatorType.DIFFERENT_FROM, "foobar");
View Full Code Here

Examples of org.apache.metamodel.schema.MutableColumn

        // define the schema
        final MutableSchema schema = new MutableSchema("s");
        MutableTable table = new MutableTable("persons", TableType.TABLE, schema);
        schema.addTable(table);
        final Column col1 = new MutableColumn("name", ColumnType.VARCHAR, table, 1, true);
        final Column col2 = new MutableColumn("role", ColumnType.VARCHAR, table, 2, true);
        final Column col3 = new MutableColumn("column_number", ColumnType.INTEGER, table, 3, true);
        table.addColumn(col1);
        table.addColumn(col2);
        table.addColumn(col3);

        Query q = new Query();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.