Search in sources :

Example 16 with Formatter

use of com.developmentontheedge.sql.format.Formatter 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

Formatter (com.developmentontheedge.sql.format.Formatter)16 Context (com.developmentontheedge.sql.format.Context)13 AstStart (com.developmentontheedge.sql.model.AstStart)12 DefaultParserContext (com.developmentontheedge.sql.model.DefaultParserContext)11 Test (org.junit.Test)10 ColumnRef (com.developmentontheedge.sql.format.ColumnRef)4 FilterApplier (com.developmentontheedge.sql.format.FilterApplier)4 Dbms (com.developmentontheedge.sql.format.Dbms)3 SqlParser (com.developmentontheedge.sql.model.SqlParser)3 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 DynamicProperty (com.developmentontheedge.beans.DynamicProperty)2 LimitsApplier (com.developmentontheedge.sql.format.LimitsApplier)2 OrderByFilter (com.developmentontheedge.sql.format.OrderByFilter)2 SQLException (java.sql.SQLException)2 SimpleDateFormat (java.text.SimpleDateFormat)2