@Override public String getCreateFulltextIndexSql(String indexName, String quotedIndexName, Table table, List<Column> columns, Model model) { String columnNames = columns.stream() .map(column -> "'" + column.getPhysicalName() + "'") .collect(Collectors.joining(", ")); String fullIndexName = String.format("PUBLIC_%s_%s", table.getPhysicalName(), indexName); return String.format("CALL NXFT_CREATE_INDEX('%s', 'PUBLIC', '%s', (%s), '%s')", fullIndexName, table.getPhysicalName(), columnNames, fulltextAnalyzer); }
@Override public List<String> getPostCreateIdentityColumnSql(Column column) { String table = column.getTable().getPhysicalName(); String col = column.getPhysicalName(); String seq = table + "_IDSEQ"; String trig = table + "_IDTRIG"; String createSeq = String.format("CREATE SEQUENCE \"%s\"", seq); String createTrig = String.format("CREATE TRIGGER \"%s\"\n" // + " BEFORE INSERT ON \"%s\"\n" // + " FOR EACH ROW WHEN (NEW.\"%s\" IS NULL)\n" // + "BEGIN\n" // + " SELECT \"%s\".NEXTVAL INTO :NEW.\"%s\" FROM DUAL;\n" // + "END;", trig, table, col, seq, col); return Arrays.asList(createSeq, createTrig); }
private Object getFieldValue(ResultSet rs, Column column) { try { int index = rs.findColumn(column.getPhysicalName()); return column.getFromResultSet(rs, index); } catch (SQLException e) { throw new DirectoryException("getFieldValue failed", e); } }
public Set<Column> getMissingColumns(Boolean breakAtFirstMissing) { try { Set<Column> missingColumns = new HashSet<>(); // Test whether there are new fields added in the schema that are // not present in the table schema. If so it is advised to // reinitialise the database. Set<String> columnNames = getPhysicalColumns(); // check the field names match the column names (case-insensitive) for (Column column : table.getColumns()) { // TODO: check types as well String fieldName = column.getPhysicalName(); if (!columnNames.contains(fieldName)) { log.debug(String.format("required field: %s is missing", fieldName)); missingColumns.add(column); if (breakAtFirstMissing) { return null; } } } return missingColumns; } catch (SQLException e) { log.warn("error while introspecting table: " + tableName, e); return null; } }
Column column = null; for (Column c : table.getColumns()) { String upperName = c.getPhysicalName().toUpperCase(); if (upperName.equals(columnName)) { column = c;
@Override public Column getSubQueryIdColumn() { Column column = fakeSubqueryTableAlias.getColumn(Model.MAIN_KEY); return new ArraySubQueryPostgreSQLColumn(column.getPhysicalName(), column.getType()); }
/** * 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)); } }
Column fc = ft.getColumn(column.getForeignKey()); String constraintName = dialect.openQuote() + dialect.getForeignKeyConstraintName(key, column.getPhysicalName(), ft.getPhysicalName()) + dialect.closeQuote(); StringBuilder buf = new StringBuilder(); true)); if (dialect.supportsCircularCascadeDeleteConstraints() || (Model.MAIN_KEY.equals(fc.getPhysicalName()) && Model.MAIN_KEY.equals(column.getPhysicalName()))) {
String upperName = column.getPhysicalName().toUpperCase(); Integer type = columnTypes.remove(upperName); if (type == null) {