@Override public String getKey() { return table.getKey(); }
/** * Patches the Tag join to join on the relation target instead of the hierarchy id. */ @Override protected void addJoin(int kind, String alias, Table table, String column, Table contextTable, String contextColumn, String name, int index, String primaryType) { if (table.getKey().equals(SCHEMA_TAG)) { kind = Join.INNER; contextTable = relationTable; contextColumn = PROPERTY_TARGET; } super.addJoin(kind, alias, table, column, contextTable, contextColumn, name, index, null); }
@Override public List<String> getCustomPostCreateSqls(Table table, Model model) { if (!needsClusteredColumn(table)) { return Collections.emptyList(); } String quotedIndexName = getIndexName(table.getKey(), Collections.singletonList(CLUSTER_INDEX_COL)); String sql = String.format("CREATE UNIQUE CLUSTERED INDEX [%s] ON %s ([%s])", quotedIndexName, table.getQuotedName(), CLUSTER_INDEX_COL); return Collections.singletonList(sql); }
@Override protected String getSelectColName(Column col) { String name = super.getSelectColName(col); if (firstSelectedColumn == null) { firstSelectedColumn = col; } if (type == COUNT_SOURCE && col.getTable().getKey().equals(SCHEMA_RELATION) && col.getKey().equals(PROPERTY_SOURCE)) { name = String.format("COUNT(DISTINCT %s)", name); } return name; }
@Override public List<String> getCustomPostCreateSqls(Table table, Model model) { List<String> sqls = new ArrayList<>(); String key = table.getKey(); if (childNameUniqueConstraintEnabled && key.equals(Model.HIER_TABLE_NAME)) {
/** * Gets a CREATE INDEX statement for an index. * * @param indexName the index name (for fulltext) * @param indexType the index type * @param table the table * @param columns the columns to index * @param model the model */ public String getCreateIndexSql(String indexName, Table.IndexType indexType, Table table, List<Column> columns, Model model) { List<String> qcols = new ArrayList<>(columns.size()); List<String> pcols = new ArrayList<>(columns.size()); for (Column col : columns) { qcols.add(col.getQuotedName()); pcols.add(col.getPhysicalName()); } String quotedIndexName = openQuote() + getIndexName(table.getKey(), pcols) + closeQuote(); if (indexType == Table.IndexType.FULLTEXT) { return getCreateFulltextIndexSql(indexName, quotedIndexName, table, columns, model); } else { String unique = indexType == Table.IndexType.UNIQUE ? "UNIQUE " : ""; return String.format("CREATE %sINDEX %s ON %s (%s)", unique, quotedIndexName, table.getQuotedName(), String.join(", ", qcols)); } }
String where = String.join(" AND ", wheres) + getSoftDeleteClause(table.getKey()); select.setWhere(where); List<String> orders = new LinkedList<>();