[#6105] Add Name { Field | Table | Schema | Catalog }.getUnqualifiedName()

This commit is contained in:
lukaseder 2017-04-19 14:20:28 +02:00
parent 37654f4335
commit 37b16cbe32
10 changed files with 44 additions and 4 deletions

View File

@ -56,6 +56,11 @@ public interface Catalog extends QueryPart {
*/
Name getQualifiedName();
/**
* The unqualified name of this catalog.
*/
Name getUnqualifiedName();
/**
* List all schemas contained in this catalog.
*/

View File

@ -102,6 +102,11 @@ public interface Field<T> extends SelectField<T>, GroupField, FieldOrRow {
*/
Name getQualifiedName();
/**
* The unqualified name of this field.
*/
Name getUnqualifiedName();
/**
* The comment given to the field.
* <p>

View File

@ -60,6 +60,11 @@ public interface Schema extends QueryPart {
*/
Name getQualifiedName();
/**
* The unqualified name of this schema.
*/
Name getUnqualifiedName();
/**
* Stream all tables contained in this schema.
*/

View File

@ -95,6 +95,11 @@ public interface Table<R extends Record> extends TableLike<R> {
*/
Name getQualifiedName();
/**
* The unqualified name of this table.
*/
Name getUnqualifiedName();
/**
* The comment given to the table.
* <p>

View File

@ -217,6 +217,11 @@ abstract class AbstractField<T> extends AbstractQueryPart implements Field<T> {
return name;
}
@Override
public final Name getUnqualifiedName() {
return name.unqualifiedName();
}
@Override
public final String getComment() {
return comment;

View File

@ -395,6 +395,11 @@ abstract class AbstractTable<R extends Record> extends AbstractQueryPart impleme
return tablename;
}
@Override
public final Name getUnqualifiedName() {
return tablename.unqualifiedName();
}
@Override
public final String getComment() {
return tablecomment;

View File

@ -83,6 +83,11 @@ public class CatalogImpl extends AbstractQueryPart implements Catalog {
return name;
}
@Override
public final Name getUnqualifiedName() {
return name.unqualifiedName();
}
@Override
public final void accept(Context<?> ctx) {
ctx.visit(name.unqualifiedName());

View File

@ -104,6 +104,11 @@ public class SchemaImpl extends AbstractQueryPart implements Schema {
return name;
}
@Override
public final Name getUnqualifiedName() {
return name.unqualifiedName();
}
@Override
public final void accept(Context<?> ctx) {
Catalog mappedCatalog = Tools.getMappedCatalog(ctx.configuration(), getCatalog());

View File

@ -204,7 +204,7 @@ public class TableImpl<R extends Record> extends AbstractTable<R> {
}
}
ctx.visit(Tools.getMappedTable(ctx.configuration(), this).getQualifiedName().unqualifiedName());
ctx.visit(Tools.getMappedTable(ctx.configuration(), this).getUnqualifiedName());
if (parameters != null && ctx.declareTables()) {

View File

@ -1972,7 +1972,7 @@ final class Tools {
String separator = "";
for (Field<?> field : list) {
context.sql(separator).visit(field.getQualifiedName().unqualifiedName());
context.sql(separator).visit(field.getUnqualifiedName());
separator = ", ";
}
@ -1994,7 +1994,7 @@ final class Tools {
String separator = "";
for (Table<?> table : list) {
context.sql(separator).visit(table.getQualifiedName().unqualifiedName());
context.sql(separator).visit(table.getUnqualifiedName());
separator = ", ";
}
@ -3636,7 +3636,7 @@ final class Tools {
Name[] part = table.getQualifiedName().parts();
Name[] name = new Name[part.length + 1];
System.arraycopy(part, 0, name, 0, part.length);
name[part.length] = field.getQualifiedName().unqualifiedName();
name[part.length] = field.getUnqualifiedName();
return DSL.field(DSL.name(name), field.getDataType());
}