#include <DBSchemaGenerator.h>
Inheritance diagram for DBSchemaGenerator:
Public Types | |
typedef std::set< CStdString > | TableColumnsSet |
Public Member Functions | |
int | generateColumnTypes (DatabaseSqlStatements *sqlStatements, CStdString &warningsForUser, CStdString &errorForUser) |
int | generateCreationScript (DatabaseSqlStatements *sqlStatements, bool generateComments, CStdString &creationSql, CStdString &warningsForUser, CStdString &errorForUser) |
int | generateDropScript (DatabaseSqlStatements *sqlStatements, CStdString &dropSql, CStdString &warningsForUser, CStdString &errorForUser) |
int | generateExplainScript (DatabaseSqlStatements *sqlStatements, CStdString &explainSql, CStdString &warningsForUser, CStdString &errorForUser) |
Protected Member Functions | |
int | generateViews (DatabaseSqlStatements *sqlStatements, bool generateComments, CStdString &viewsSql, CStdString &warningsForUser, CStdString &errorForUser) |
int | generateSimpleView (FullClassInfo *classInfo, DatabaseSqlStatements *sqlStatements, CStdString &createViewSql, CStdString &warningsForUser, CStdString &errorForUser) |
int | generateSimpleViewSelectHorizontal (FullClassInfo *classInfo, DatabaseSqlStatements *sqlStatements, CStdString &selectStmt, std::list< CStdString > &viewColumns, CStdString &warningsForUser, CStdString &errorForUser) |
int | generateSimpleViewSelectVertical (FullClassInfo *classInfo, DatabaseSqlStatements *sqlStatements, CStdString &selectStmt, std::list< CStdString > &viewColumns, CStdString &warningsForUser, CStdString &errorForUser) |
int | generateSimpleViewSelectFiltered (FullClassInfo *classInfo, DatabaseSqlStatements *sqlStatements, CStdString &selectStmt, std::list< CStdString > &viewColumns, CStdString &warningsForUser, CStdString &errorForUser) |
void | addParentsTables (FullClassInfo *classInfo, std::map< CStdString, TableColumnsSet > &tables) |
int | generatePolymorphicView (FullClassInfo *classInfo, DatabaseSqlStatements *sqlStatements, CStdString &createViewSql, CStdString &warningsForUser, CStdString &errorForUser) |
void | generatePolymorphicViewHelper (FullClassInfo *classInfo, std::list< FullClassInfo * > &horizontalAncestors, std::list< int > &classIDsForMainSelect, bool addClassIDs) |
int | generateTableComment (const TableInfo *tableInfo, DatabaseSqlStatements *sqlStatements, CStdString &tableComment, CStdString &warningsForUser, CStdString &errorForUser) |
void | generateClassIDs () |
Static Protected Member Functions | |
void | qualifyColumnNames (const std::list< CStdString > &columnNames, const std::map< CStdString, TableColumnsSet > &tables, std::list< CStdString > &qualifiedColumnNames) |
Inherited from ClassHierarchy it has the data to proceed.
All public functions of this class takes pointer to DatabaseSqlStatements as parameter. Pointed object is used to make it possible to generate different SQL for different databases / database vendors.
|
Set of columns in one table. Used by addParentsTables().
|
|
Generates DB column type for every persistent class attribute, for which the user hasn't set it in XML. If the user has set it, checks whether the type is correct.
|
|
Generates SQL script that creates all tables, views, indexes etc. that are needed for the application to run. Calls generateTableInfoMap() to acquire information about tables that should be generated, generates support for OID generation (DatabaseSqlStatements::generateOidGenerationSupportCreationScript()), project's class ID table, project's main table (+ index on it). Then generates all common class tables (+ indexes on class IDs if needed), fills in project's main table and calls generateViews() to get definitions of all views needed for application to run.
|
|
Generates SQL script that drops all tables, views, indexes etc. created by script generated by generateCreationScript().
|
|
Generates SQL script that can be used to explain execution plans for getting data from classes' simple and polymorphic view (i.e. SELECT * FROM <view_name>).
|
|
Generates script that can be used to create simple and polymorphic views for all classes. Traverses classMap and for each class calls generateSimpleView() and generatePolymorphicView().
|
|
Generates SQL statement that creates simple view for given class ( According to class's mappingType calls one of these functions: generateSimpleViewSelectHorizontal(), generateSimpleViewSelectVertical(), generateSimpleViewSelectFiltered(). Then takes acquired SELECT statement and generates CREATE VIEW statement from it using DatabaseSqlStatements::generateCreateViewSql().
|
|
Generates SELECT part of SQL statement that creates simple view for given class ( The creation of the SELECT is trivial in this case - it's enough to SELECT all the columns from class's table (FullClassInfo::dbTable) that don't belong to any of class's filtered ancestors. WHERE clause selects only the rows with the right class ID.
|
|
Generates SELECT part of SQL statement that creates simple view for given class (
The SELECT is more complicated in this case. Firstly, map of tables that contain data from this class is created (using addParentsTables()), then all these tables are joined using OID. WHERE clause specifies only the rows with the right class ID and only columns coming from
|
|
Generates SELECT part of SQL statement that creates simple view for given class (
Map of tables that contain data from this class is created (using addParentsTables()), then all these tables are joined using OID. WHERE clause specifies only the rows with the right class ID and only columns coming from
|
|
Walks through all
|
|
Due to multiple inheritance it is sometimes necessary to specify column names fully qualified if creating views (if we have two horizontal mapping ancestors that inherit from one class and some descendant of the two classes uses filtered or vertical mapping).
This function fully qualifies given
|
|
Generates SQL statement that creates polymorphic view for given class (
Columns of the view corresponds to persistent attributes of
Gets all
The last SELECT is the main one. It is similar to the select of
|
|
Helper function used by generatePolymorphicView()
Adds
|
|
Generates comment that says which attributes of
|
|
Traverses the class hierarchy and sets FullClassInfo::classID using a counter, starting from 1. |