The create table statement now lists the inherited tables and inherited columns are commented out.
This commit is contained in:
parent
498233d58c
commit
6c76c70a97
11 changed files with 118 additions and 6 deletions
|
|
@ -1,7 +1,9 @@
|
|||
#include "PgClass.h"
|
||||
#include "PgAttributeContainer.h"
|
||||
#include "PgClassContainer.h"
|
||||
#include "PgDatabaseCatalog.h"
|
||||
#include "PgConstraintContainer.h"
|
||||
#include "PgInheritsContainer.h"
|
||||
#include <QStringBuilder>
|
||||
#include "SqlFormattingUtils.h"
|
||||
|
||||
|
|
@ -93,6 +95,7 @@ QString PgClass::createTableSql() const
|
|||
first = false;
|
||||
}
|
||||
else sql += ",\n ";
|
||||
if (!col.islocal) sql += "-- ";
|
||||
sql += col.columnDefinition(catalog());
|
||||
}
|
||||
// { column_name data_type [ COLLATE collation ] [ column_constraint [ ... ] ]
|
||||
|
|
@ -110,7 +113,20 @@ QString PgClass::createTableSql() const
|
|||
}
|
||||
|
||||
sql += ")";
|
||||
// [ INHERITS ( parent_table [, ... ] ) ]
|
||||
{
|
||||
// [ INHERITS ( parent_table [, ... ] ) ]
|
||||
auto parents = catalog().inherits()->getParentsOf(oid());
|
||||
if (!parents.empty()) {
|
||||
sql += "\nINHERITS (";
|
||||
bool first = true;
|
||||
for (auto parent_oid : parents) {
|
||||
if (first) first = false;
|
||||
else sql += ", ";
|
||||
sql += catalog().classes()->getByKey(parent_oid)->fullyQualifiedQuotedObjectName();
|
||||
}
|
||||
sql += ")";
|
||||
}
|
||||
}
|
||||
// [ PARTITION BY { RANGE | LIST } ( { column_name | ( expression ) } [ COLLATE collation ] [ opclass ] [, ... ] ) ]
|
||||
// [ WITH ( storage_parameter [= value] [, ... ] ) | WITH OIDS | WITHOUT OIDS ]
|
||||
// [ ON COMMIT { PRESERVE ROWS | DELETE ROWS | DROP } ]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue