[#3094] Add Relations.getUniqueKeys(SchemaDefinition), getUniqueKeys()
This commit is contained in:
parent
e66bac60ef
commit
1848481b28
@ -208,6 +208,24 @@ public class DefaultRelations implements Relations {
|
||||
return new ArrayList<UniqueKeyDefinition>(result);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public List<UniqueKeyDefinition> getUniqueKeys(SchemaDefinition schema) {
|
||||
Set<UniqueKeyDefinition> result = new LinkedHashSet<UniqueKeyDefinition>();
|
||||
|
||||
for (TableDefinition table : schema.getDatabase().getTables(schema)) {
|
||||
result.addAll(getUniqueKeys(table));
|
||||
}
|
||||
|
||||
return new ArrayList<UniqueKeyDefinition>(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UniqueKeyDefinition> getUniqueKeys() {
|
||||
return new ArrayList<UniqueKeyDefinition>(uniqueKeys.values());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ForeignKeyDefinition> getForeignKeys(ColumnDefinition column) {
|
||||
if (foreignKeysByColumn == null) {
|
||||
|
||||
@ -69,6 +69,18 @@ public interface Relations {
|
||||
*/
|
||||
List<UniqueKeyDefinition> getUniqueKeys(TableDefinition table);
|
||||
|
||||
/**
|
||||
* Get a list of all referenced keys (primary or unique) for a given schema.
|
||||
* Returns an empty list if the given schema has no primary or unique keys.
|
||||
*/
|
||||
List<UniqueKeyDefinition> getUniqueKeys(SchemaDefinition schema);
|
||||
|
||||
/**
|
||||
* Get a list of all referenced keys (primary or unique). Returns an empty
|
||||
* list if there are no primary or unique keys.
|
||||
*/
|
||||
List<UniqueKeyDefinition> getUniqueKeys();
|
||||
|
||||
/**
|
||||
* Get a list of foreign keys for a given table, that the column
|
||||
* participates in. Returns an empty list if the given column is not part of
|
||||
|
||||
Loading…
Reference in New Issue
Block a user