Search in sources :

Example 1 with WhereWrapper

use of com.github.mgramin.sqlboot.model.resource_type.wrappers.list.WhereWrapper in project sql-boot by sql-boot.

the class SqlResourceTypeTest method read2.

@Test
public void read2() {
    final String sql = "select * from (select table_schema as \"@table_schema\", table_name as \"@table_name\", column_name as \"@column_name\"" + "from information_schema.columns)";
    ResourceType type = new WhereWrapper(new SqlResourceType(new JdbcSqlQuery(dataSource, new GroovyTemplateGenerator(sql)), asList("column")));
    assertEquals(8, type.read(new DbUri("column/main_schema.users")).count());
}
Also used : DbUri(com.github.mgramin.sqlboot.model.uri.impl.DbUri) JdbcSqlQuery(com.github.mgramin.sqlboot.sql.impl.JdbcSqlQuery) ResourceType(com.github.mgramin.sqlboot.model.resource_type.ResourceType) GroovyTemplateGenerator(com.github.mgramin.sqlboot.template.generator.impl.GroovyTemplateGenerator) WhereWrapper(com.github.mgramin.sqlboot.model.resource_type.wrappers.list.WhereWrapper) Test(org.junit.Test)

Example 2 with WhereWrapper

use of com.github.mgramin.sqlboot.model.resource_type.wrappers.list.WhereWrapper 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());
}
Also used : DbUri(com.github.mgramin.sqlboot.model.uri.impl.DbUri) JdbcSqlQuery(com.github.mgramin.sqlboot.sql.impl.JdbcSqlQuery) ResourceType(com.github.mgramin.sqlboot.model.resource_type.ResourceType) GroovyTemplateGenerator(com.github.mgramin.sqlboot.template.generator.impl.GroovyTemplateGenerator) WhereWrapper(com.github.mgramin.sqlboot.model.resource_type.wrappers.list.WhereWrapper) Test(org.junit.Test)

Aggregations

ResourceType (com.github.mgramin.sqlboot.model.resource_type.ResourceType)2 WhereWrapper (com.github.mgramin.sqlboot.model.resource_type.wrappers.list.WhereWrapper)2 DbUri (com.github.mgramin.sqlboot.model.uri.impl.DbUri)2 JdbcSqlQuery (com.github.mgramin.sqlboot.sql.impl.JdbcSqlQuery)2 GroovyTemplateGenerator (com.github.mgramin.sqlboot.template.generator.impl.GroovyTemplateGenerator)2 Test (org.junit.Test)2