All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.easy.query.mssql.func.MsSQLLengthSQLFunction Maven / Gradle / Ivy

There is a newer version: 2.3.3
Show newest version
package com.easy.query.mssql.func;

import com.easy.query.core.expression.func.AggregationType;
import com.easy.query.core.expression.parser.core.available.TableAvailable;
import com.easy.query.core.func.column.ColumnExpression;
import com.easy.query.core.func.def.AbstractExpressionSQLFunction;
import com.easy.query.core.util.EasyCollectionUtil;

import java.util.List;

/**
 * create time 2023/10/18 09:52
 * 文件说明
 *
 * @author xuejiaming
 */
public class MsSQLLengthSQLFunction extends AbstractExpressionSQLFunction{
    private final List columnExpressions;

    public MsSQLLengthSQLFunction(List columnExpressions) {

        this.columnExpressions = columnExpressions;
    }

    @Override
    public String sqlSegment(TableAvailable defaultTable) {
        Iterable params = EasyCollectionUtil.select(columnExpressions, (t, i) -> "{" + i + "}");
        return String.format("LEN(%s)", String.join(",", params));
    }

    @Override
    public int paramMarks() {
        return columnExpressions.size();
    }

    @Override
    protected List getColumnExpressions() {
        return columnExpressions;
    }

    @Override
    public AggregationType getAggregationType() {
        return AggregationType.LENGTH;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy