use of com.github.mgramin.sqlboot.sql.impl.JdbcSqlQuery in project sql-boot by sql-boot.
the class SqlResourceTypeTest method read.
@Test
public void read() throws Exception {
final String sql = "select * from (select table_schema as \"@table_schema\", table_name as \"@table_name\" " + "from information_schema.tables)";
final ResourceType type = new WhereWrapper(new SqlResourceType(new JdbcSqlQuery(dataSource, new GroovyTemplateGenerator(sql)), asList("table")));
assertEquals(3, type.read(new DbUri("table/m.column")).count());
}
use of com.github.mgramin.sqlboot.sql.impl.JdbcSqlQuery in project sql-boot by sql-boot.
the class SqlResourceTypeTest method path.
@Test
public void path() {
final String sql = "select _schema, _table, _column from (select table_schema as \"_schema\", table_name as \"_table\", column_name as \"_column\"" + "from information_schema.columns)";
final ResourceType type = new SqlResourceType(new JdbcSqlQuery(dataSource, new GroovyTemplateGenerator(sql)), asList("column"));
final List<String> path = type.path();
assertEquals("schema", path.get(0));
assertEquals("table", path.get(1));
assertEquals("column", path.get(2));
}
Aggregations