convertToSqlBooleanQuery(sb, first, query, context, td); return; validateTerm(term); if (term.matchType == null) { term.matchType = QueryTask.QueryTerm.MatchType.TERM; ColumnDescription cd = getColumnDescription(td, query.term.propertyName); if (cd == null && context != null && context.nativeSearcher != null) { if ((cd = getColumnDescription(td2, query.term.propertyName)) != null) { break; condition = SQL_FALSE; } else if (term.range != null) { condition = convertToSqlNumericRangeQuery(query, cd); } else { if (term.matchType == QueryTask.QueryTerm.MatchType.WILDCARD) { condition = convertToSqlLikeQuery(query, cd); } else if (term.matchType == QueryTask.QueryTerm.MatchType.PHRASE) { condition = convertToSqlPhraseQuery(query, cd); } else if (term.matchType == QueryTask.QueryTerm.MatchType.PREFIX) { condition = convertToSqlPrefixQuery(query, cd); } else { condition = convertToSqlSingleTermQuery(query, cd); convertQueryCondition(sb, first, query, condition);
static String convert(Query query, QueryRuntimeContext context, TableDescription td) { query = reduceQuery(query, td); try { if (query.occurance == null) { query.occurance = QueryTask.Query.Occurance.MUST_OCCUR; } StringBuilder condition = builderPerThread.get(); convertToPostgresQuery(condition, true, query, context, td); String sql = condition.toString(); if (logger.isLoggable(Level.FINE)) { logger.fine(String.format("Convert: %s\n%s", sql, Utils.toJsonHtml(query))); } return sql; } catch (Exception e) { logger.severe(() -> String.format("Conversion failed: %s", Utils.toString(e))); throw new RuntimeException(e); } }
static String convertToPostgresGroupField(QueryTask.QueryTerm term, TableDescription td) { return convertToPostgresSortField(term, false, td); }
convertQueryOccurance(sb, first, query); ColumnDescription cd = getColumnDescription(td, q.term.propertyName); boolean isCaseInsensitive = isCaseInsensitive(cd); if (cd == null || (isCaseInsensitive && isCollectionField(q))) { skip = true; + next.term.matchValue.length() + 10); values.append('\'') .append(escapeSqlString( isCaseInsensitive ? q.term.matchValue.toLowerCase() : q.term.matchValue)) .append(escapeSqlString( isCaseInsensitive ? next.term.matchValue.toLowerCase() : next.term.matchValue)) if (isCollectionField(q)) { if (cd.getParent() != null) { cd = cd.getParent(); case SHOULD_OCCUR: condition = String.format("%s ?| ARRAY[%s]", wrapNativeField(q.term.propertyName, cd), values); break; case MUST_OCCUR: default: condition = String.format("%s ?& ARRAY[%s]", wrapNativeField(q.term.propertyName, cd), values);
if (isSqlFalse(tq)) { return null; String rq = PostgresQueryConverter.convert(resourceQuery, null, td); if (isSqlFalse(rq)) { return null; if (!isSqlTrue(rq)) { if (sb.length() > 0) { sb.append(" AND "); return tq; if (isSqlTrue(tq)) { return sb.toString();
sortFields = PostgresQueryConverter.convertToPostgresSort(qs, false, tables.iterator().next(), true); TableDescription td = tables.iterator().next(); String where = tq != null ? tq : PostgresQueryConverter.convert(qs.query, qs.context, td); where = updateQuery(op, td, where, queryStartTimeMicros, qs, false); if (where == null) { .map(td -> { String where = tq != null ? tq : PostgresQueryConverter.convert(qs.query, qs.context, td); where = updateQuery(op, td, where, queryStartTimeMicros, qs, false); if (where == null) { if (bottom != null) { after = PostgresQueryConverter .buildPaginationClause(tables.iterator().next(), sortFields, bottom);
String groupBy = PostgresQueryConverter.convertToPostgresGroupField(qs.groupByTerm, firstTable); if (groupBy == null) { if (qs.groupSortTerm != null) { groupSortFields = PostgresQueryConverter .convertToPostgresSort(qs, true, firstTable, false); TableDescription td = tables.iterator().next(); String where = tq != null ? tq : PostgresQueryConverter.convert(qs.query, qs.context, td); where = updateQuery(op, td, where, startTimeMillis, qs, true); if (where == null) { .map(td -> { String where = tq != null ? tq : PostgresQueryConverter.convert(qs.query, qs.context, td); where = updateQuery(op, td, where, startTimeMillis, qs, true); if (where == null) {
sortFields = PostgresQueryConverter.convertToPostgresSort(task.querySpec, false, td, true); task.querySpec.context.nativeSort = sortFields;
.map(td -> { String where = tq != null ? tq : PostgresQueryConverter.convert(qs.query, qs.context, td); where = updateQuery(op, td, where, queryStartTimeMicros, qs, false); if (where == null) { TableDescription td = tables.iterator().next(); String where = tq != null ? tq : PostgresQueryConverter.convert(qs.query, qs.context, td); where = updateQuery(op, td, where, queryStartTimeMicros, qs, false); if (where == null) {
List<String> sortFields = new ArrayList<>(allocationSize); sortFields.add(convertToPostgresSortField(sortTerm, true, td)); boolean addDocumentSelfLink = !sortTerm.propertyName .equals(ServiceDocument.FIELD_NAME_SELF_LINK); for (int index = 1; index < len; index++) { QueryTask.QueryTerm qt = additionalSortTerms.get(index - 1); sortFields.add(convertToPostgresSortField(qt, true, td)); if (qt.propertyName.equals(ServiceDocument.FIELD_NAME_SELF_LINK)) { addDocumentSelfLink = false;