Search in sources :

Example 1 with Ast

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

the class Be5QueryExecutor method hasColumnWithLabel.

private boolean hasColumnWithLabel(AstStart ast, String idColumnLabel) {
    AstQuery query = ast.getQuery();
    Optional<AstSelect> selectOpt = query.children().select(AstSelect.class).collect(MoreCollectors.onlyOne());
    if (!selectOpt.isPresent())
        return false;
    AstSelect select = selectOpt.get();
    return select.getSelectList().children().select(AstDerivedColumn.class).map(AstDerivedColumn::getAlias).nonNull().map(alias -> alias.replaceFirst("^\"(.+)\"$", "$1")).has(idColumnLabel);
}
Also used : AstSelect(com.developmentontheedge.sql.model.AstSelect) Connection(java.sql.Connection) DynamicPropertySet(com.developmentontheedge.beans.DynamicPropertySet) ContextApplier(com.developmentontheedge.sql.format.ContextApplier) AstParenthesis(com.developmentontheedge.sql.model.AstParenthesis) Meta(com.developmentontheedge.be5.api.services.Meta) Query(com.developmentontheedge.be5.metadata.model.Query) SqlQuery(com.developmentontheedge.sql.model.SqlQuery) ColumnAdder(com.developmentontheedge.sql.format.ColumnAdder) ResultSetParser(com.developmentontheedge.be5.api.sql.ResultSetParser) UserInfoHolder(com.developmentontheedge.be5.api.helpers.UserInfoHolder) Map(java.util.Map) AstLimit(com.developmentontheedge.sql.model.AstLimit) Be5Exception(com.developmentontheedge.be5.api.exceptions.Be5Exception) Context(com.developmentontheedge.sql.format.Context) AstDerivedColumn(com.developmentontheedge.sql.model.AstDerivedColumn) MoreCollectors(one.util.streamex.MoreCollectors) Set(java.util.Set) PreparedStatement(java.sql.PreparedStatement) Logger(java.util.logging.Logger) EntityModel(com.developmentontheedge.be5.databasemodel.EntityModel) Objects(java.util.Objects) List(java.util.List) QueryType(com.developmentontheedge.be5.metadata.QueryType) LimitsApplier(com.developmentontheedge.sql.format.LimitsApplier) Simplifier(com.developmentontheedge.sql.format.Simplifier) AstBeParameterTag(com.developmentontheedge.sql.model.AstBeParameterTag) AstOrderBy(com.developmentontheedge.sql.model.AstOrderBy) StreamEx(one.util.streamex.StreamEx) DatabaseConstants(com.developmentontheedge.be5.metadata.DatabaseConstants) Optional(java.util.Optional) FilterHelper(com.developmentontheedge.be5.api.helpers.FilterHelper) RecordModel(com.developmentontheedge.be5.databasemodel.RecordModel) ResultSetMetaData(java.sql.ResultSetMetaData) AstIdentifierConstant(com.developmentontheedge.sql.model.AstIdentifierConstant) AstQuery(com.developmentontheedge.sql.model.AstQuery) DatabaseService(com.developmentontheedge.be5.api.services.DatabaseService) QueryContext(com.developmentontheedge.sql.format.QueryContext) HashMap(java.util.HashMap) AstStart(com.developmentontheedge.sql.model.AstStart) Token(com.developmentontheedge.sql.model.Token) ArrayList(java.util.ArrayList) Level(java.util.logging.Level) Entity(com.developmentontheedge.be5.metadata.model.Entity) SQLException(java.sql.SQLException) Formatter(com.developmentontheedge.sql.format.Formatter) Injector(com.developmentontheedge.be5.env.Injector) DynamicPropertySetSupport(com.developmentontheedge.beans.DynamicPropertySetSupport) ParserContext(com.developmentontheedge.sql.model.ParserContext) AstSelect(com.developmentontheedge.sql.model.AstSelect) DefaultParserContext(com.developmentontheedge.sql.model.DefaultParserContext) SqlService(com.developmentontheedge.be5.api.services.SqlService) DynamicProperty(com.developmentontheedge.beans.DynamicProperty) DatabaseModel(com.developmentontheedge.be5.databasemodel.impl.DatabaseModel) DpsRecordAdapter(com.developmentontheedge.be5.api.sql.DpsRecordAdapter) Ast(com.developmentontheedge.sql.format.Ast) AstTableRef(com.developmentontheedge.sql.model.AstTableRef) AstNumericConstant(com.developmentontheedge.sql.model.AstNumericConstant) UserAwareMeta(com.developmentontheedge.be5.api.helpers.UserAwareMeta) AstOrderingElement(com.developmentontheedge.sql.model.AstOrderingElement) AstBeSqlSubQuery(com.developmentontheedge.sql.model.AstBeSqlSubQuery) Collections(java.util.Collections) AstQuery(com.developmentontheedge.sql.model.AstQuery)

Aggregations

Be5Exception (com.developmentontheedge.be5.api.exceptions.Be5Exception)1 FilterHelper (com.developmentontheedge.be5.api.helpers.FilterHelper)1 UserAwareMeta (com.developmentontheedge.be5.api.helpers.UserAwareMeta)1 UserInfoHolder (com.developmentontheedge.be5.api.helpers.UserInfoHolder)1 DatabaseService (com.developmentontheedge.be5.api.services.DatabaseService)1 Meta (com.developmentontheedge.be5.api.services.Meta)1 SqlService (com.developmentontheedge.be5.api.services.SqlService)1 DpsRecordAdapter (com.developmentontheedge.be5.api.sql.DpsRecordAdapter)1 ResultSetParser (com.developmentontheedge.be5.api.sql.ResultSetParser)1 EntityModel (com.developmentontheedge.be5.databasemodel.EntityModel)1 RecordModel (com.developmentontheedge.be5.databasemodel.RecordModel)1 DatabaseModel (com.developmentontheedge.be5.databasemodel.impl.DatabaseModel)1 Injector (com.developmentontheedge.be5.env.Injector)1 DatabaseConstants (com.developmentontheedge.be5.metadata.DatabaseConstants)1 QueryType (com.developmentontheedge.be5.metadata.QueryType)1 Entity (com.developmentontheedge.be5.metadata.model.Entity)1 Query (com.developmentontheedge.be5.metadata.model.Query)1 DynamicProperty (com.developmentontheedge.beans.DynamicProperty)1 DynamicPropertySet (com.developmentontheedge.beans.DynamicPropertySet)1 DynamicPropertySetSupport (com.developmentontheedge.beans.DynamicPropertySetSupport)1