Search in sources :

Example 11 with DefaultParserContext

use of com.developmentontheedge.sql.model.DefaultParserContext in project be5 by DevelopmentOnTheEdge.

the class OrderByFilterTest method testOrderByFilter.

@Test
public void testOrderByFilter() {
    AstStart start = SqlQuery.parse("SELECT t.a, t.b, t.c AS foo FROM myTable t WHERE t.b > 2");
    Map<String, String> columns = new HashMap<String, String>();
    columns.put("t.a", "ASC");
    columns.put("foo", "DESC");
    new OrderByFilter().apply(start, columns);
    assertEquals("SELECT t.a, t.b, t.c AS foo FROM myTable t WHERE t.b > 2 ORDER BY 1 ASC, 3 DESC", 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) HashMap(java.util.HashMap) Formatter(com.developmentontheedge.sql.format.Formatter) DefaultParserContext(com.developmentontheedge.sql.model.DefaultParserContext) OrderByFilter(com.developmentontheedge.sql.format.OrderByFilter) Test(org.junit.Test)

Aggregations

Context (com.developmentontheedge.sql.format.Context)11 Formatter (com.developmentontheedge.sql.format.Formatter)11 DefaultParserContext (com.developmentontheedge.sql.model.DefaultParserContext)11 AstStart (com.developmentontheedge.sql.model.AstStart)10 Test (org.junit.Test)9 ColumnRef (com.developmentontheedge.sql.format.ColumnRef)4 FilterApplier (com.developmentontheedge.sql.format.FilterApplier)4 ProjectElementException (com.beanexplorer.enterprise.metadata.exception.ProjectElementException)2 Entity (com.beanexplorer.enterprise.metadata.model.Entity)2 Project (com.beanexplorer.enterprise.metadata.model.Project)2 Query (com.beanexplorer.enterprise.metadata.model.Query)2 LoadContext (com.beanexplorer.enterprise.metadata.serialization.LoadContext)2 Rdbms (com.beanexplorer.enterprise.metadata.sql.Rdbms)2 Dbms (com.developmentontheedge.sql.format.Dbms)2 OrderByFilter (com.developmentontheedge.sql.format.OrderByFilter)2 SqlParser (com.developmentontheedge.sql.model.SqlParser)2 SimpleDateFormat (java.text.SimpleDateFormat)2 LinkedHashMap (java.util.LinkedHashMap)2 Map (java.util.Map)2 ProcessInterruptedException (com.beanexplorer.enterprise.metadata.exception.ProcessInterruptedException)1