Strip last char.

@param columnFamilyQuery
the column family query
@param queryBuilder
the query builder
@return the string builder
554931
private StringBuilder replaceColumnsAndStripLastChar(String columnFamilyQuery, StringBuilder queryBuilder)
    {
        // strip last ",".
        if (queryBuilder.length() > 0)
        {
            queryBuilder.deleteCharAt(queryBuilder.length() - 1);

            columnFamilyQuery = StringUtils.replace(columnFamilyQuery, CQLTranslator.COLUMNS, queryBuilder.toString());
            queryBuilder = new StringBuilder(columnFamilyQuery);
        }
        return queryBuilder;
    }
550831
public function _UpdateQueryBuilder(Builder $objBuilder)
    {
        $intLength = count($this->objNodeArray);
        for ($intIndex = 0; $intIndex < $intLength; $intIndex++) {
            $objNode = $this->objNodeArray[$intIndex];
            if ($objNode instanceof Node\Virtual) {
                if ($objNode->hasSubquery()) {
                    throw new Caller('You cannot define a virtual node in an order by clause. You must use an Expand clause to define it.');
                }
                $strOrderByCommand = '__' . $objNode->getAttributeName();
            } elseif ($objNode instanceof Node\Column) {
                /** @var Node\Column $objNode */
                $strOrderByCommand = $objNode->getColumnAlias($objBuilder);
            } elseif ($objNode instanceof iCondition) {
                /** @var iCondition $objNode */
                $strOrderByCommand = $objNode->getWhereClause($objBuilder);
            } else {
                $strOrderByCommand = '';
            }

            // Check to see if they want a ASC/DESC declarator
            if ((($intIndex + 1) < $intLength) &&
                !($this->objNodeArray[$intIndex + 1] instanceof Node\NodeBase)
            ) {
                if ((!$this->objNodeArray[$intIndex + 1]) ||
                    (trim(strtolower($this->objNodeArray[$intIndex + 1])) == 'desc')
                ) {
                    $strOrderByCommand .= ' DESC';
                } else {
                    $strOrderByCommand .= ' ASC';
                }
                $intIndex++;
            }

            $objBuilder->addOrderByItem($strOrderByCommand);
        }
    }
439472
void processColumnFamily(ByteBuffer key, ColumnFamily cf, QueryOptions options, long now, Selection.ResultSetBuilder result)
    throws InvalidRequestException
    {
        CFMetaData cfm = cf.metadata();
        ByteBuffer[] keyComponents = null;
        if (cfm.getKeyValidator() instanceof CompositeType)
        {
            keyComponents = ((CompositeType)cfm.getKeyValidator()).split(key);
        }
        else
        {
            keyComponents = new ByteBuffer[]{ key };
        }

        Iterator<Cell> cells = cf.getSortedColumns().iterator();
        if (sliceRestriction != null)
            cells = applySliceRestriction(cells, options);

        CQL3Row.RowIterator iter = cfm.comparator.CQL3RowBuilder(cfm, now).group(cells);

        // If there is static columns but there is no non-static row, then provided the select was a full
        // partition selection (i.e. not a 2ndary index search and there was no condition on clustering columns)
        // then we want to include the static columns in the result set (and we're done).
        CQL3Row staticRow = iter.getStaticRow();
        if (staticRow != null && !iter.hasNext() && !usesSecondaryIndexing && hasNoClusteringColumnsRestriction())
        {
            result.newRow();
            for (ColumnDefinition def : selection.getColumns())
            {
                switch (def.kind)
                {
                    case PARTITION_KEY:
                        result.add(keyComponents[def.position()]);
                        break;
                    case STATIC:
                        addValue(result, def, staticRow, options);
                        break;
                    default:
                        result.add((ByteBuffer)null);
                }
            }
            return;
        }

        while (iter.hasNext())
        {
            CQL3Row cql3Row = iter.next();

            // Respect requested order
            result.newRow();
            // Respect selection order
            for (ColumnDefinition def : selection.getColumns())
            {
                switch (def.kind)
                {
                    case PARTITION_KEY:
                        result.add(keyComponents[def.position()]);
                        break;
                    case CLUSTERING_COLUMN:
                        result.add(cql3Row.getClusteringColumn(def.position()));
                        break;
                    case COMPACT_VALUE:
                        result.add(cql3Row.getColumn(null));
                        break;
                    case REGULAR:
                        addValue(result, def, cql3Row, options);
                        break;
                    case STATIC:
                        addValue(result, def, staticRow, options);
                        break;
                }
            }
        }
    }
1302293
private static void selectWithQueryBuilder(CqlSession session) {
    // Reading the whole row as a JSON object:
    Statement stmt =
        selectFrom("examples", "querybuilder_json")
            .json()
            .all()
            .whereColumn("id")
            .isEqualTo(literal(1))
            .build();
    Row row = session.execute(stmt).one();
    assert row != null;
    System.out.printf("Entry #1 as JSON: %s%n", row.getString("[json]"));

    // Extracting a particular column as JSON:
    stmt =
        selectFrom("examples", "querybuilder_json")
            .column("id")
            .function("toJson", Selector.column("specs"))
            .as("json_specs")
            .whereColumn("id")
            .isEqualTo(literal(2))
            .build();

    row = session.execute(stmt).one();
    assert row != null;

    System.out.printf(
        "Entry #%d's specs as JSON: %s%n", row.getInt("id"), row.getString("json_specs"));
  }
1322392
public String getColumnHolder(String entityName, String suffix, String separator) {
        StringBuffer sb = new StringBuffer("#{");
        if (StringUtil.isNotEmpty(entityName)) {
            sb.append(entityName);
            sb.append(".");
        }
        sb.append(this.property);
        if (StringUtil.isNotEmpty(suffix)) {
            sb.append(suffix);
        }
        //如果 null 被当作值来传递，对于所有可能为空的列，JDBC Type 是需要的
        if (this.jdbcType != null) {
            sb.append(", jdbcType=");
            sb.append(this.jdbcType.toString());
        }
        //为了以后定制类型处理方式，你也可以指定一个特殊的类型处理器类，例如枚举
        if (this.typeHandler != null) {
            sb.append(", typeHandler=");
            sb.append(this.typeHandler.getCanonicalName());
        }
        //3.4.0 以前的 mybatis 无法获取父类中泛型的 javaType，所以如果使用低版本，就需要设置 useJavaType = true
        //useJavaType 默认 false,没有 javaType 限制时，对 ByPrimaryKey 方法的参数校验就放宽了，会自动转型
        if (useJavaType && !this.javaType.isArray()) {//当类型为数组时，不设置javaType#103
            sb.append(", javaType=");
            sb.append(javaType.getCanonicalName());
        }
        sb.append("}");
        if (StringUtil.isNotEmpty(separator)) {
            sb.append(separator);
        }
        return sb.toString();
    }
1049497
public function compileResequenceQuery(QueryBuilder $queryBuilder, ResequenceOrderIndexColumn $query) : \Dms\Core\Persistence\Db\Platform\CompiledQuery
    {
        $platform         = $queryBuilder->getConnection()->getDatabasePlatform();
        $tableName        = $platform->quoteSingleIdentifier($query->getTable()->getName());
        $subSelectTable   = $platform->quoteSingleIdentifier($query->getTable()->getName() . '__inner');
        $orderIndexColumn = $platform->quoteSingleIdentifier($query->getColumn()->getName());

        $subSelect = $queryBuilder->getConnection()->createQueryBuilder();
        $subSelect
                ->from($tableName, $subSelectTable)
                ->select('COUNT(*) AS row_number')
                ->where($queryBuilder->expr()->lte(
                        $subSelectTable . '.' . $orderIndexColumn,
                        $tableName . '.' . $orderIndexColumn
                ));

        if ($query->hasGroupingColumn()) {
            $groupingColumn = $platform->quoteSingleIdentifier($query->getGroupingColumn()->getName());

            $subSelect->andWhere($queryBuilder->expr()->eq(
                    $subSelectTable . '.' . $groupingColumn,
                    $tableName . '.' . $groupingColumn
            ));
        }

        $queryBuilder
                ->update($tableName)
                ->set($orderIndexColumn, '(' . $subSelect->getSQL() . ')');

        if ($query->hasWhereCondition()) {
            $queryBuilder->where(
                    $this->expressionCompiler->compileExpression($queryBuilder, $query->getWhereCondition())
            );
        }

        return new CompiledQuery($queryBuilder->getSQL(), $queryBuilder->getParameters());
    }
723584
public static String getColumnFamily(Tree astNode, Iterable<CfDef> cfDefs)
    {
        return getColumnFamily(CliUtils.unescapeSQLString(astNode.getChild(0).getText()), cfDefs);
    }
398010
public TermsByQueryRequest query(QueryBuilder queryBuilder) {
    this.querySource = queryBuilder == null ? null : queryBuilder.buildAsBytes();
    return this;
  }
780651
public function getRelationExistenceQueryForSelfRelation(Builder $query, Builder $parentQuery, $columns = ['*'])
    {
        $query->from($query->getModel()->getTable().' as '.$hash = $this->getRelationCountHash());

        $query->join($this->throughChild->getTable(), $this->getQualifiedParentKeyName(), '=', $hash.'.'.$this->ownerKey);

        if ($this->throughChildSoftDeletes()) {
            $query->whereNull($this->throughChild->getQualifiedDeletedAtColumn());
        }

        $query->getModel()->setTable($hash);

        return $query->whereColumn(
            $hash.'.'.$query->getModel()->qualifyColumn($this->secondKey), '=', $this->getQualifiedSecondOwnerKeyName()
        );
    }
915506
protected function getQueryBuilderByFamily(Request $request, FamilyInterface $family)
    {
        $term = '%'.trim($request->get('term'), '%').'%';

        return $this->dataManager->getQbForFamiliesAndLabel([$family], $term);
    }
736785
public Where<T, ID> notIn(String columnName, QueryBuilder<?, ?> subQueryBuilder) throws SQLException {
		return in(false, columnName, subQueryBuilder);
	}
1103647
private void validateAndAppendColumnName(CQLTranslator translator, StringBuilder queryBuilder, String b,
            Class<?> clazz)
    {
        String dataType = CassandraValidationClassMapper.getValidationClass(clazz, true);
        translator.appendColumnName(queryBuilder, b, translator.getCQLType(dataType));
        queryBuilder.append(Constants.SPACE_COMMA);
    }
314696
private String getExtractQuery(String schema, String entity, String inputQuery) {
    String inputColProjection = this.getInputColumnProjection();
    String outputColProjection = this.getOutputColumnProjection();
    String query = inputQuery;
    if (query == null) {
      // if input query is null, build the query from metadata
      query = "SELECT " + outputColProjection + " FROM " + schema + "." + entity;
    } else {
      // replace input column projection with output column projection
      if (StringUtils.isNotBlank(inputColProjection)) {
        query = query.replace(inputColProjection, outputColProjection);
      }
    }

    query = addOptionalWatermarkPredicate(query);
    return query;
  }
739870
@Override
    protected List<IPersonAttributes> getPeopleForQuery(final PartialWhereClause queryBuilder, final String queryUserName) {
        //Execute the query
        final RowMapper<R> rowMapper = this.getRowMapper();

        final List<R> results;
        if (queryBuilder != null) {
            //Merge the generated SQL with the base query template
            final StringBuilder partialSqlWhere = queryBuilder.sql;
            final Matcher queryMatcher = WHERE_PLACEHOLDER.matcher(this.queryTemplate);
            final String querySQL = queryMatcher.replaceAll(partialSqlWhere.toString());

            results = this.simpleJdbcTemplate.query(querySQL, rowMapper, queryBuilder.arguments.toArray());

            if (this.logger.isDebugEnabled()) {
                this.logger.debug("Executed '" + this.queryTemplate + "' with arguments " + queryBuilder.arguments + " and got results " + results);
            }
        } else {
            results = this.simpleJdbcTemplate.query(this.queryTemplate, rowMapper);

            if (this.logger.isDebugEnabled()) {
                this.logger.debug("Executed '" + this.queryTemplate + "' and got results " + results);
            }
        }

        return this.parseAttributeMapFromResults(results, queryUserName);
    }
938613
public static function filterRangeDate(
        QueryBuilder $queryBuilder,
        &$criteria,
        $field,
        $fieldFrom,
        $fieldTo,
        $alias = 'o'
    ) {
        if (isset($criteria[$fieldFrom]) || isset($criteria[$fieldTo]) && $criteria[$fieldTo] != '') {
            if (!empty($criteria[$fieldFrom])) {
                $from = $criteria[$fieldFrom].' 00:00:00';
                $queryBuilder
                    ->andWhere($queryBuilder->expr()->gte(sprintf('%s.%s', $alias, $field), sprintf(':%s', $fieldFrom)))
                    ->setParameter($fieldFrom, \DateTime::createFromFormat('d/m/Y H:i:s', $from));
            }
            unset($criteria[$fieldFrom]);
            if (!empty($criteria[$fieldTo])) {
                $to = $criteria[$fieldTo].' 23:59:59';
                $queryBuilder
                    ->andWhere($queryBuilder->expr()->lte(sprintf('%s.%s', $alias, $field), sprintf(':%s', $fieldTo)))
                    ->setParameter($fieldTo, \DateTime::createFromFormat('d/m/Y H:i:s', $to));
            }
            unset($criteria[$fieldTo]);
        }

        return $criteria;
    }
485343
public static StringBuilder removeLast(final StringBuilder builder, final String string) {
		final int lastIndexOf = builder.lastIndexOf(string);
		if (lastIndexOf == -1) {
			return builder;
		}
		return new StringBuilder(builder.substring(0, lastIndexOf));
	}
662702
private ByteBuffer columnNameAsBytes(String column, String columnFamily)
    {
        CfDef columnFamilyDef = getCfDef(columnFamily);
        return columnNameAsBytes(column, columnFamilyDef);
    }