Search in sources :

Example 1 with CategoryFilter

use of com.developmentontheedge.sql.format.CategoryFilter in project be5 by DevelopmentOnTheEdge.

the class CategoryFilterTest method testCategoryFilter.

@Test
public void testCategoryFilter() {
    AstStart start = SqlQuery.parse("SELECT t.a, q.b FROM myTable t, otherTable q JOIN oneMoreTable a ON (a.ID=q.ID) WHERE t.b > 2");
    new CategoryFilter("myTable", "ID", 123).apply(start);
    assertEquals("SELECT t.a, q.b FROM myTable t " + "INNER JOIN classifications ON classifications.categoryID = 123 " + "AND classifications.recordID = t.ID, otherTable q " + "INNER JOIN oneMoreTable a ON (a.ID = q.ID) " + "WHERE t.b > 2", new Formatter().format(start, new Context(Dbms.MYSQL), new DefaultParserContext()));
}
Also used : Context(com.developmentontheedge.sql.format.Context) DefaultParserContext(com.developmentontheedge.sql.model.DefaultParserContext) AstStart(com.developmentontheedge.sql.model.AstStart) Formatter(com.developmentontheedge.sql.format.Formatter) DefaultParserContext(com.developmentontheedge.sql.model.DefaultParserContext) CategoryFilter(com.developmentontheedge.sql.format.CategoryFilter) Test(org.junit.Test)

Aggregations

CategoryFilter (com.developmentontheedge.sql.format.CategoryFilter)1 Context (com.developmentontheedge.sql.format.Context)1 Formatter (com.developmentontheedge.sql.format.Formatter)1 AstStart (com.developmentontheedge.sql.model.AstStart)1 DefaultParserContext (com.developmentontheedge.sql.model.DefaultParserContext)1 Test (org.junit.Test)1