private Collection<ColumnDescription> getAllChildren() { if (this.children == null || this.children.isEmpty()) { return Collections.emptySet(); } Collection<ColumnDescription> children = new HashSet<>(this.children); this.children.forEach(c -> { children.addAll(c.getAllChildren()); }); return children; }
.filter(cd -> !cd.isNativeColumn() && cd.getDataColumnLevel() == 0) .forEach(column -> addColumnIndex(td, tableId, column, columnIds, indexIds, documentSelfLinkColumnId));
@Override public Element createNode(LiquibaseSerializable object) { Element element = super.createNode(object); if (object instanceof ChangeSet) { ChangeSet changeSet = (ChangeSet) object; changeSet.getChanges().forEach(change -> { if (change instanceof CreateIndexChange) { CreateIndexChange cic = (CreateIndexChange) change; if (cic.getColumns().size() != 1) { return; } ColumnDescription cd = this.currentSnapshot .getColumnDescriptionByIndexId(cic.getIndexName()); String indexType = cd != null ? cd.getIndexType() : null; if (indexType != null) { Document doc = element.getOwnerDocument(); Element modifySqlElement = doc.createElement("modifySql"); Element replaceElement = doc.createElement("regExpReplace"); replaceElement.setAttribute("replace", "\\(.+\\)"); replaceElement.setAttribute("with", String.format(" USING %s $0", indexType)); modifySqlElement.appendChild(replaceElement); element.appendChild(modifySqlElement); } } }); } return element; } }
String condition; if (isCollectionField(q)) { if (cd.getParent() != null) { cd = cd.getParent(); default: if (valueCount == 1) { if (cd.isNativeColumn()) { condition = String.format("%s = %s", stringField, values); } else {
propertyName); ColumnDescription cd = new ColumnDescription(); cd.propertyName = absolutePropertyName; cd.table = this; cd.parent = parent; if (parent != null) { parent.addChild(cd); boolean isJsonType = cd.getParent() != null ? cd.getParent().isJsonType() : cd.isJsonType(); boolean isTextType = cd.getParent() != null ? cd.getParent().isTextType() : cd.isTextType();
if (cd.getPropertyDescription().elementDescription != null) { typeName = cd.getPropertyDescription().elementDescription.typeName; } else { typeName = cd.getPropertyDescription().typeName;
&& cd.getPropertyDescription().typeName == ServiceDocumentDescription.TypeName.MAP && isCaseInsensitive) { isCaseInsensitive = false; if (cd != null && !isCaseInsensitive && !cd.isNativeColumn()) { String condition = toJsonContainsCondition(query, cd); if (condition != null) {
Map<String, String> columnIds, Map<String, String> indexIds, String documentSelfLinkColumnId) { String typeName = columnDescription.getColumnType(); String columnName = columnDescription.getColumnName(); boolean isNativeColumn = columnDescription.isNativeColumn(); switch (columnDescription.getPropertyName()) { case ServiceDocument.FIELD_NAME_SELF_LINK: case ServiceDocument.FIELD_NAME_VERSION: String indexType = columnDescription.getIndexType(); boolean isIndex = indexType != null; if (!isNativeColumn && !isIndex) { String indexNameSuffix = columnDescription.getPropertyName(); PropertyDescription propertyDescription = columnDescription.getPropertyDescription(); if (!columnDescription.isNativeColumn() && columnDescription.isTextType() && propertyDescription.indexingOptions.contains(PropertyIndexingOption.CASE_INSENSITIVE)) { indexColumnName = String.format("lower(%s)", columnDescription.getColumnNameAsText()); indexNameSuffix = "lower_" + indexNameSuffix; if (!indexColumnName.equalsIgnoreCase(columnDescription.getPropertyName())) { indexColumnName = "(" + indexColumnName + ")";
private static String wrapField(String propertyName, ColumnDescription cd, String expectedType) { String columnName; if (cd != null && cd.getPropertyName().equals(propertyName)) { if (isTextType(expectedType)) { return cd.getColumnNameAsText(); } if (expectedType == null || cd.isNativeColumn() || cd.getColumnType().equals(expectedType)) { return cd.getColumnName(); } return String.format("(%s)::%s", cd.getColumnNameAsText(), expectedType); } boolean isExpectedJsonType = expectedType == null || isJsonbType(expectedType); String typeSuffix = !isExpectedJsonType ? ">" : ""; propertyName = normalizePropertyName(propertyName); if (propertyName.contains(".")) { columnName = String.format("data #>%s '{%s}'", typeSuffix, escapeSqlString(propertyName.replace('.', ','))); } else { columnName = String.format("data ->%s '%s'", typeSuffix, escapeSqlString(propertyName)); } if (!isExpectedJsonType) { return String.format("(%s)::%s", columnName, expectedType); } return columnName; }
private static boolean isTextIndexingOption(ColumnDescription cd) { return cd != null && cd.getPropertyDescription().indexingOptions .contains(PropertyIndexingOption.TEXT); }
private static boolean isCaseInsensitive(ColumnDescription cd) { return cd != null && cd.getPropertyDescription().indexingOptions .contains(PropertyIndexingOption.CASE_INSENSITIVE); }