com.easy.query.gauss.db.func.GaussDBConcatSQLFunction Maven / Gradle / Ivy
The newest version!
package com.easy.query.gauss.db.func;
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/11 22:45
* 文件说明
*
* @author xuejiaming
*/
public class GaussDBConcatSQLFunction extends AbstractExpressionSQLFunction {
private final List columnExpressions;
public GaussDBConcatSQLFunction(List concatExpressions) {
if (EasyCollectionUtil.isEmpty(concatExpressions)) {
throw new IllegalArgumentException("PgSQLConcatSQLFunction columns empty");
}
this.columnExpressions = concatExpressions;
}
@Override
public String sqlSegment(TableAvailable defaultTable) {
Iterable params = EasyCollectionUtil.select(columnExpressions, (t, i) -> "{" + i + "}");
// return String.format("%s", String.join(" || ", params));
return String.format("CONCAT(%s)", String.join(",", params));
}
@Override
public int paramMarks() {
return columnExpressions.size();
}
@Override
protected List getColumnExpressions() {
return columnExpressions;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy