Appends post type constraint.
@param types The types.
@param sql The buffer to append to.
@return The input buffer.
329221
private StringBuilder appendPostTypes(final EnumSet<Post.Type> types, final StringBuilder sql) {
      int typesCount = types != null ? types.size() : 0;
      switch(typesCount) {
         case 0:
            break;
         case 1:
            sql.append(" AND post_type=").append(String.format("'%s'", types.iterator().next().toString()));
            break;
         default:
            sql.append(" AND post_type IN (");
            sql.append(inJoiner.join(types.stream().map(t -> String.format("'%s'", t.toString())).collect(Collectors.toSet())));
            sql.append(")");
            break;
      }

      return sql;
   }
5818
public static Set<String> getSqlParams(final String sql) {
		SqlParser parser = new SqlParserImpl(sql);
		ContextTransformer transformer = parser.parse();
		Node rootNode = transformer.getRoot();

		Set<String> params = new LinkedHashSet<>();
		traverseNode(rootNode, params);
		params.removeIf(s -> CONSTANT_PAT.matcher(s).matches());
		return params;
	}
731765
public <T> List<List<T>> queryTypedResults(String sql, String[] args) {
		return db.queryTypedResults(sql, args);
	}
429401
public int insert(String sql, Object value) {
        Class<?> parameterType = value != null ? value.getClass() : null;
        String msId = msUtils.insertDynamic(sql, parameterType);
        return sqlSession.insert(msId, value);
    }
856412
public static String appendPageParams(String sql, PageRow pageRow) {
        if (null == pageRow) {
            return sql;
        }
        return Base.dialect.getPagingSql(sql, pageRow);
    }
1078833
public boolean addRequiredParams(JSType ...types) {
    if (hasOptionalOrVarArgs()) {
      return false;
    }

    for (JSType type : types) {
      newParameter(type);
    }
    return true;
  }
590276
public static String formatSQL(String sql) {
		if (sql == null || sql.length() == 0)
			return sql;
		StringBuilder sb = new StringBuilder();
		char[] chars = sql.toCharArray();
		boolean addedSpace = false;
		for (char c : chars) {
			if (isInvisibleChar(c)) {
				if (!addedSpace) {
					sb.append(" ");
					addedSpace = true;
				}
			} else {
				sb.append(c);
				addedSpace = false;
			}
		}
		sb.append(" ");
		return sb.toString();
	}
1187978
@ObjectiveCName("appendArrayGenericType:types:")
    public static void appendArrayGenericType(StringBuilder out, Type[] types) {
        if (types.length == 0) {
            return;
        }
        appendGenericType(out, types[0]);
        for (int i = 1; i < types.length; i++) {
            out.append(',');
            appendGenericType(out, types[i]);
        }
    }
253879
public <S> List<S> queryList(Class<S> type, String sql, Object[] params) {
        Connection conn = getConn();
        try {
            return conn.createQuery(sql)
                    .withParams(params)
                    .setColumnMappings(computeModelColumnMappings(type))
                    .throwOnMappingFailure(false)
                    .executeAndFetch(type);
        } finally {
            this.closeConn(conn);
            this.clean(null);
        }
    }
846376
public CodeElement addSupportingType(String type) {
        CodeElement codeElement = new CodeElement(type);
        codeElement.setRole(CodeElementRole.Supporting);
        this.codeElements.add(codeElement);

        return codeElement;
    }
350554
protected void appendStringType(StringBuilder sb, FieldType fieldType, int fieldWidth) {
		if (isVarcharFieldWidthSupported()) {
			sb.append("VARCHAR(").append(fieldWidth).append(')');
		} else {
			sb.append("VARCHAR");
		}
	}
126688
public Binder insert(int index, Class<?>[] types, Object... values) {
        return new Binder(this, new Insert(index, types, values));
    }
1260250
public static TextProtocolBackendHandler newInstance(final String sql, final BackendConnection backendConnection) {
        if (sql.toUpperCase().startsWith(ShardingCTLBackendHandlerFactory.SCTL)) {
            return ShardingCTLBackendHandlerFactory.newInstance(sql, backendConnection);
        }
        // TODO use sql parser engine instead of string compare
        Optional<TransactionOperationType> transactionOperationType = TransactionOperationType.getOperationType(sql.toUpperCase());
        if (transactionOperationType.isPresent()) {
            return new TransactionBackendHandler(transactionOperationType.get(), backendConnection);
        }
        if (sql.toUpperCase().contains(SET_AUTOCOMMIT_1)) {
            return backendConnection.getStateHandler().isInTransaction() ? new TransactionBackendHandler(TransactionOperationType.COMMIT, backendConnection) : new SkipBackendHandler();
        }
        SQLStatement sqlStatement = new SQLJudgeEngine(sql).judge();
        return SQLType.DAL == sqlStatement.getType() ? createDALBackendHandler(sqlStatement, sql, backendConnection) : new QueryBackendHandler(sql, backendConnection);
    }
672152
public boolean addPostTerm(final long postId, final TaxonomyTerm taxonomyTerm) throws SQLException {

      List<TaxonomyTerm> currTerms = selectPostTerms(postId, taxonomyTerm.taxonomy);
      for(TaxonomyTerm currTerm : currTerms) {
         if(currTerm.term.name.equals(taxonomyTerm.term.name)) {
            return false;
         }
      }

      Connection conn = null;
      PreparedStatement stmt = null;
      Timer.Context ctx = metrics.postTermsSetTimer.time();
      try {
         conn = connectionSupplier.getConnection();
         stmt = conn.prepareStatement(insertPostTermSQL);
         stmt.setLong(1, postId);
         stmt.setLong(2, taxonomyTerm.id);
         stmt.setInt(3, currTerms.size()); //Add at the last position...
         return stmt.executeUpdate() > 0;
      } finally {
         ctx.stop();
         SQLUtil.closeQuietly(conn, stmt);
      }
   }
892351
public @NotNull QueryBuilder append(@NotNull String sql, @NotNull Collection<?> args) {
        query.append(requireNonNull(sql));
        addArguments(args);
        return this;
    }
1127610
public int insert(String sql) {
        String msId = msUtils.insert(sql);
        return sqlSession.insert(msId);
    }
640050
@Override
    public boolean supportsResultSetType(int type) throws SQLException
    {
        checkClosed();
        if (type == ResultSet.TYPE_SCROLL_INSENSITIVE)
            return true;
        return false;
    }