Examples of toSql()


Examples of org.apache.metamodel.query.Query.toSql()

    Table table = dc.getDefaultSchema().getTableByName("table");
    Query query = dc.query().from(table).select(table.getColumns())
        .toQuery();
    assertEquals("SELECT table.foo, table.bar FROM schema.table",
        query.toSql());

    DataSet ds = dc.executeQuery(query);
    assertEquals(ConvertedDataSet.class, ds.getClass());

    assertTrue(ds.next());
View Full Code Here

Examples of org.apache.metamodel.query.Query.toSql()

        new StringToIntegerConverter());

    // only select "bar" which is not converted
    Table table = converted.getDefaultSchema().getTableByName("table");
    Query query = converted.query().from(table).select("bar").toQuery();
    assertEquals("SELECT table.bar FROM schema.table", query.toSql());

    DataSet ds = converted.executeQuery(query);
    assertEquals(InMemoryDataSet.class, ds.getClass());

  }
View Full Code Here

Examples of org.apache.metamodel.query.Query.toSql()

        Map<Column, TypeConverter<?, ?>> converters = Converters.autoDetectConverters(dc, table, 1000);
        assertEquals(1, converters.size());
        dc = Converters.addTypeConverters(dc, converters);

        final Query q = dc.query().from(table).select("foo").toQuery();
        assertEquals("SELECT table.foo FROM schema.table", q.toSql());
        DataSet ds = dc.executeQuery(q);
        assertTrue(ds.next());
        assertEquals(1, ds.getRow().getValue(0));
        assertTrue(ds.next());
        assertEquals(2, ds.getRow().getValue(0));
View Full Code Here

Examples of org.apache.metamodel.query.Query.toSql()

      assertEquals(
          "SELECT /employee./name AS employee, /organization./name AS company "
              + "FROM /root./employee INNER JOIN /root./organization "
              + "ON /employee.index(/root/organization) = /organization.row_id",
          q.toSql());

      DataSet ds = dc.executeQuery(q);
      assertTrue(ds.next());
      assertEquals("Row[values=[John Doe, Company A]]", ds.getRow()
          .toString());
View Full Code Here

Examples of org.apache.metamodel.query.Query.toSql()

        String[] columnNames = table.getColumnNames();
        assertEquals("[A, B, C, D]", Arrays.toString(columnNames));

        Query q = dc.query().from(table).select(table.getColumnByName("A")).toQuery();
        assertEquals("SELECT xls_people.A FROM xls_people.xls.xls_people", q.toSql());

        DataSet dataSet = dc.executeQuery(q);
        assertTrue(dataSet.next());
        assertEquals("id", dataSet.getRow().getValue(0));
        for (int i = 1; i <= 9; i++) {
View Full Code Here

Examples of org.apache.metamodel.query.Query.toSql()

        String[] columnNames = table.getColumnNames();
        assertEquals("[1, mike, male, 18]", Arrays.toString(columnNames));

        Query q = dc.query().from(table).select(table.getColumnByName("1")).toQuery();
        assertEquals("SELECT xls_people.1 FROM xls_people.xls.xls_people", q.toSql());

        DataSet dataSet = dc.executeQuery(q);
        assertTrue(dataSet.next());
        assertEquals("2", dataSet.getRow().getValue(0));
        for (int i = 3; i <= 9; i++) {
View Full Code Here

Examples of org.apache.metamodel.query.Query.toSql()

        File file = new File("src/test/resources/csv_people.csv");
        QueryPostprocessDataContext dc = new CsvDataContext(file, new CsvConfiguration(1, true, true));
        Table table = dc.getDefaultSchema().getTableByName("csv_people.csv");

        Query q = dc.query().from(table).as("t").select("name").and("age").where("age").in("18", "20").toQuery();
        assertEquals("SELECT t.name, t.age FROM resources.csv_people.csv t WHERE t.age IN ('18' , '20')", q.toSql());

        DataSet ds = dc.executeQuery(q);
        assertTrue(ds.next());
        assertEquals("Row[values=[mike, 18]]", ds.getRow().toString());
        assertTrue(ds.next());
View Full Code Here

Examples of org.apache.metamodel.query.Query.toSql()

        dc = Converters.addTypeConverters(dc, converters);

        Table table = dc.getDefaultSchema().getTables()[0];
        MutableColumn col = (MutableColumn) table.getColumns()[0];
        Query q = dc.query().from(table).select(col).toQuery();
        assertEquals("SELECT csv_only_number_one.csv.number FROM resources.csv_only_number_one.csv", q.toSql());

        DataSet ds = dc.executeQuery(q);
        while (ds.next()) {
            assertEquals(true, ds.getRow().getValue(0));
        }
View Full Code Here

Examples of org.apache.metamodel.query.Query.toSql()

    public void testSelectAlias() throws Exception {
        Query q = MetaModelHelper.parseQuery(dc, "SELECT foo AS f FROM sch.tbl");
        assertEquals("SELECT tbl.foo AS f FROM sch.tbl", q.toSql());

        q = MetaModelHelper.parseQuery(dc, "SELECT a.foo AS foobarbaz FROM sch.tbl a WHERE foobarbaz = '123'");
        assertEquals("SELECT a.foo AS foobarbaz FROM sch.tbl a WHERE foobarbaz = '123'", q.toSql());
    }

    public void testSelectDistinct() throws Exception {
        Query q = MetaModelHelper.parseQuery(dc, "SELECT DISTINCT foo, bar AS f FROM sch.tbl");
        assertEquals("SELECT DISTINCT tbl.foo, tbl.bar AS f FROM sch.tbl", q.toSql());
View Full Code Here

Examples of org.apache.metamodel.query.Query.toSql()

        assertEquals("SELECT a.foo AS foobarbaz FROM sch.tbl a WHERE foobarbaz = '123'", q.toSql());
    }

    public void testSelectDistinct() throws Exception {
        Query q = MetaModelHelper.parseQuery(dc, "SELECT DISTINCT foo, bar AS f FROM sch.tbl");
        assertEquals("SELECT DISTINCT tbl.foo, tbl.bar AS f FROM sch.tbl", q.toSql());
    }

    public void testSimpleSelectFrom() throws Exception {
        Query q = MetaModelHelper.parseQuery(dc, "SELECT foo\nFROM sch.tbl");
        assertEquals("SELECT tbl.foo FROM sch.tbl", q.toSql());
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.