use of org.jooq.Catalog in project jOOQ by jOOQ.
the class AbstractMetaDatabase method getCatalogs0.
@Override
protected List<CatalogDefinition> getCatalogs0() throws SQLException {
List<CatalogDefinition> result = new ArrayList<>();
for (Catalog catalog : getCatalogsFromMeta()) result.add(new CatalogDefinition(this, catalog.getName(), ""));
result.sort(COMP);
return result;
}
use of org.jooq.Catalog in project jOOQ by jOOQ.
the class InformationSchemaExport method exportCatalogs.
static final InformationSchema exportCatalogs(Configuration configuration, List<Catalog> catalogs) {
InformationSchema result = new InformationSchema();
Set<Table<?>> includedTables = new LinkedHashSet<>();
for (Catalog c : catalogs) for (Schema s : c.getSchemas()) includedTables.addAll(s.getTables());
for (Catalog c : catalogs) {
exportCatalog0(result, c);
for (Schema s : c.getSchemas()) {
exportSchema0(result, s);
for (Domain<?> d : s.getDomains()) exportDomain0(configuration, result, d);
for (Table<?> t : s.getTables()) exportTable0(configuration, result, t, includedTables);
for (Sequence<?> q : s.getSequences()) exportSequence0(configuration, result, q);
}
}
return result;
}
use of org.jooq.Catalog in project jOOQ by jOOQ.
the class DefaultParseContext method parseRename.
private final DDLQuery parseRename() {
parseKeyword("RENAME");
switch(characterUpper()) {
case 'C':
if (parseKeywordIf("COLUMN")) {
TableField<?, ?> oldName = parseFieldName();
parseKeyword("AS", "TO");
return dsl.alterTable(oldName.getTable()).renameColumn(oldName).to(parseFieldName());
}
break;
case 'D':
if (parseKeywordIf("DATABASE")) {
Catalog oldName = parseCatalogName();
parseKeyword("AS", "TO");
return dsl.alterDatabase(oldName).renameTo(parseCatalogName());
}
break;
case 'I':
if (parseKeywordIf("INDEX")) {
Name oldName = parseIndexName();
parseKeyword("AS", "TO");
return dsl.alterIndex(oldName).renameTo(parseIndexName());
}
break;
case 'S':
if (parseKeywordIf("SCHEMA")) {
Schema oldName = parseSchemaName();
parseKeyword("AS", "TO");
return dsl.alterSchema(oldName).renameTo(parseSchemaName());
} else if (parseKeywordIf("SEQUENCE")) {
Sequence<?> oldName = parseSequenceName();
parseKeyword("AS", "TO");
return dsl.alterSequence(oldName).renameTo(parseSequenceName());
}
break;
case 'V':
if (parseKeywordIf("VIEW")) {
Table<?> oldName = parseTableName();
parseKeyword("AS", "TO");
return dsl.alterView(oldName).renameTo(parseTableName());
}
break;
}
// If all of the above fails, we can assume we're renaming a table.
parseKeywordIf("TABLE");
Table<?> oldName = parseTableName();
parseKeyword("AS", "TO");
return dsl.alterTable(oldName).renameTo(parseTableName());
}
use of org.jooq.Catalog in project jOOQ by jOOQ.
the class AbstractMeta method lookupTable.
final Table<?> lookupTable(Table<?> table) {
// TODO: This is a re-occurring pattern in Meta implementations. Should we have a more generic way to look up objects in a Catalog/Schema?
Catalog catalog = getCatalog(table.getCatalog().getName());
if (catalog == null)
return null;
Schema schema = catalog.getSchema(table.getSchema().getName());
if (schema == null)
return null;
return schema.getTable(table.getName());
}
use of org.jooq.Catalog in project jOOQ by jOOQ.
the class SchemaImpl method accept.
@Override
public final void accept(Context<?> ctx) {
if (ctx.qualifyCatalog()) {
Catalog mappedCatalog = getMappedCatalog(ctx, getCatalog());
if (mappedCatalog != null && !"".equals(mappedCatalog.getName()))
ctx.visit(mappedCatalog).sql('.');
}
Schema mappedSchema = getMappedSchema(ctx, this);
ctx.visit(mappedSchema != null ? mappedSchema.getUnqualifiedName() : getUnqualifiedName());
}
Aggregations