kexi
KexiDB::QuerySchema Class Reference
#include <queryschema.h>
Inheritance diagram for KexiDB::QuerySchema:

Detailed Description
KexiDB::QuerySchema provides information about database query that can be executed using SQL database engine.
Definition at line 77 of file queryschema.h.
Public Member Functions | |
QuerySchema () | |
QuerySchema (TableSchema *tableSchema) | |
virtual | ~QuerySchema () |
virtual FieldList & | insertField (uint position, Field *field) |
FieldList & | insertField (uint position, Field *field, bool visible) |
FieldList & | insertField (uint position, Field *field, int bindToTable, bool visible=true) |
FieldList & | addField (Field *field, bool visible=true) |
FieldList & | addField (Field *field, int bindToTable, bool visible=true) |
virtual void | removeField (Field *field) |
bool | isColumnVisible (uint position) const |
void | setColumnVisible (uint position, bool v) |
FieldList & | addAsterisk (QueryAsterisk *asterisk, bool visible=true) |
virtual void | clear () |
virtual QString | debugString () |
Connection * | connection () const |
TableSchema * | masterTable () const |
void | setMasterTable (TableSchema *table) |
TableSchema::List * | tables () const |
void | addTable (TableSchema *table, const QCString &alias=QCString()) |
void | removeTable (TableSchema *table) |
TableSchema * | table (const QString &tableName) const |
bool | contains (TableSchema *table) const |
Field * | findTableField (const QString &tableDotFieldName) const |
QCString | columnAlias (uint position) const |
bool | hasColumnAlias (uint position) const |
void | setColumnAlias (uint position, const QCString &alias) |
int | tableBoundToColumn (uint columnPosition) const |
QCString | tableAlias (uint position) const |
int | tablePositionForAlias (const QCString &name) const |
int | tablePosition (const QString &tableName) const |
QValueList< int > | tablePositions (const QString &tableName) const |
bool | hasTableAlias (uint position) const |
int | columnPositionForAlias (const QCString &name) const |
void | setTableAlias (uint position, const QCString &alias) |
Relationship::List * | relationships () const |
Relationship * | addRelationship (Field *field1, Field *field2) |
Field::List * | asterisks () const |
virtual Field * | field (const QString &name) |
QueryColumnInfo * | columnInfo (const QString &name) |
QueryColumnInfo::Vector | fieldsExpanded (bool unique=false) |
QMap< QueryColumnInfo *, int > | fieldsOrder () |
QValueVector< int > | pkeyFieldsOrder () |
uint | pkeyFieldsCount () |
QueryColumnInfo::List * | autoIncrementFields () |
QString | statement () const |
void | setStatement (const QString &s) |
QString | autoIncrementSQLFieldsList (Driver *driver) |
void | setWhereExpression (BaseExpr *expr) |
BaseExpr * | whereExpression () const |
void | addToWhereExpression (KexiDB::Field *field, const QVariant &value, int relation= '=') |
void | setOrderByColumnList (const QStringList &columnNames) |
void | setOrderByColumnList (const QString &column1, const QString &column2=QString::null, const QString &column3=QString::null, const QString &column4=QString::null, const QString &column5=QString::null) |
QueryColumnInfo::Vector | orderByColumnList () const |
Static Public Member Functions | |
static QString | sqlColumnsList (QueryColumnInfo::List *infolist, Driver *driver) |
Protected Member Functions | |
void | init () |
void | computeFieldsExpanded () |
Protected Attributes | |
QuerySchemaPrivate * | d |
Friends | |
class | Connection |
class | QuerySchemaPrivate |
Constructor & Destructor Documentation
|
Creates empty query object (without columns). Definition at line 269 of file queryschema.cpp. |
|
Creates query schema object that is equivalent to "SELECT * FROM table" sql command. Schema of table is used to contruct this query -- it is defined just by defining "all-tables query asterisk" (see QueryAsterisk) item. Properties such as the name and caption of the query are inherited from table schema. We consider that query schema based on table is not (a least yet) stored in a system table, so query connection is set to NULL (even if tableSchema's connection is not NULL). Id of the created query is set to 0. Definition at line 277 of file queryschema.cpp. |
Member Function Documentation
|
Adds asterisk at the and of columns list. Definition at line 445 of file queryschema.cpp. |
|
Adds field to the columns list. Also binds to a table at bindToTable position. Use bindToTable==-1 if no table should be bound.
Definition at line 416 of file queryschema.cpp. |
|
Adds field to the columns list.
Definition at line 411 of file queryschema.cpp. |
|
Adds a new relationship defined by field1 and field2. Both fields should belong to two different tables of this query. This is convenience function useful for a typical cases. It automatically creates Relationship object for this query. If one of the fields are primary keys, it will be detected and appropriate master-detail relation will be established. This functiuon does nothing if the arguments are invalid. Definition at line 962 of file queryschema.cpp. |
|
Adds table schema as one of tables used in a query. if alias is not empty, it will be assigned to this table using setTableAlias(position, alias) Definition at line 594 of file queryschema.cpp. |
|
Adds a part to WHERE expression. Simplifies creating of WHERE expression, if used instead of setWhereExpression(BaseExpr *expr). Definition at line 1032 of file queryschema.cpp. |
|
Definition at line 768 of file queryschema.cpp. |
|
Reimplemented from KexiDB::FieldList. Definition at line 975 of file queryschema.cpp. |
|
Definition at line 1015 of file queryschema.cpp. |
|
Removes all columns and their aliases from the columns list, removes all tables and their aliases from the tables list within this query. Sets master table information to NULL. Does not destroy any objects though. Clears name and all other properties.
Reimplemented from KexiDB::FieldList. Definition at line 311 of file queryschema.cpp. |
|
Definition at line 662 of file queryschema.cpp. |
|
Definition at line 732 of file queryschema.cpp. |
|
Definition at line 820 of file queryschema.cpp. |
|
If query was created using a connection, returns this connection object, otherwise NULL. Definition at line 455 of file queryschema.cpp. |
|
Definition at line 646 of file queryschema.cpp. |
|
Reimplemented from KexiDB::FieldList. Definition at line 461 of file queryschema.cpp. |
|
Example: Let query be defined by "SELECT T.B AS X, * FROM T" statement and T is table containing fields A, B, C. Expanded list of columns for the query is: T.B AS X, T.A, T.B, T.C.
Reimplemented from KexiDB::FieldList. Definition at line 783 of file queryschema.cpp. |
|
QuerySchema::fields() returns vector of fields used for the query columns, but in a case when there are asterisks defined for the query, it does not expand QueryAsterisk objects to field lists but return every asterisk as-is. This could be inconvenient when you need just a fully expanded list of fields, so this method does the work for you. If unique is true, each field is returned in the vector only once (first found field is selected). Note however, that the same field can be returned more than once if it has attached a different alias. For example, let t is TABLE( a, b ) and let query be defined by "SELECT *, a AS alfa FROM t" statement. Either fieldsExpanded(true) and fieldsExpanded(false) will return [ a, b, a (alfa) ] list. On the other hand, for query defined by "SELECT *, a FROM t" statement, fieldsExpanded(true) will return [ a, b ] list and fieldsExpanded(false) will return [ a, b, a ] list. By default, all fields are returned in the vector even if there are multiple occurences of one or more. Note: You should assign the resulted vector in your space - it will be shared and implicity copied on any modification. This method's result is cached by QuerySchema object.
Definition at line 796 of file queryschema.cpp. |
|
Definition at line 915 of file queryschema.cpp. |
|
Convenience function.
QuerySchema::table("mytable")->field("myfield") could be alternative for findTableField("mytable.myfield") but it can crash if "mytable" is not defined in the query. Definition at line 651 of file queryschema.cpp. |
|
Provided for convenience.
Definition at line 668 of file queryschema.cpp. |
|
Provided for convenience.
Definition at line 727 of file queryschema.cpp. |
|
Inserts field to the columns list at position. Inserted field will not be owned by this QuerySchema object, but still by corresponding TableSchema. As field object you can also pass KexiDB::QueryAsterisk, (see QueryAsterisk class description). Note: After inserting a field, corresponding table will be automatically added to query's tables list if it is not present there (see tables()). Field must have its table assigned. Added field will be visible. Use insertField(position, field, false) to add invisible field. Reimplemented from KexiDB::FieldList. Definition at line 324 of file queryschema.cpp. |
|
Definition at line 434 of file queryschema.cpp. |
|
Definition at line 563 of file queryschema.cpp. |
|
Definition at line 1112 of file queryschema.cpp. |
|
Examples: let table T has (ID1 INTEGER, ID2 INTEGER, A INTEGER) fields, and let (ID1, ID2) is T's primary key.
Definition at line 956 of file queryschema.cpp. |
|
Each element of the returned vector:
If there are more than one primary key's field included in the query, only first-found column (oin the fieldsExpanded() list) for each pkey's field is included. Returns empty vector if there is no master table or no master table's pkey.
Definition at line 922 of file queryschema.cpp. |
|
Definition at line 763 of file queryschema.cpp. |
|
Removes field from the columns list. Use with care. Reimplemented from KexiDB::FieldList. Definition at line 422 of file queryschema.cpp. |
|
Removes table schema from this query. This does not destroy table object but only takes it out of the list. If this table was master for the query, master table information is also invalidated. Definition at line 626 of file queryschema.cpp. |
|
Sets alias for a column at position, within the query. Passing empty string to alias clears alias for a given column. Definition at line 673 of file queryschema.cpp. |
|
Sets visibility flag for column at position to v.
Definition at line 439 of file queryschema.cpp. |
|
Sets master table of this query to table. This table should be also added to query's tables list using addTable(). If table equals NULL, nothing is performed.
Definition at line 583 of file queryschema.cpp. |
|
Convenience method, similar to setOrderByColumnList(const QStringList&). Definition at line 1100 of file queryschema.cpp. |
|
Sets a list of columns for ORDER BY section of the query. Each name on the list must be a field or alias present within the query and must not be covered by aliases. If one or more names cannot be found within the query, the method will have no effect. Any previous ORDER BY settings will be removed. Definition at line 1088 of file queryschema.cpp. |
|
Forces a query statement (i.e. no statement is composed from QuerySchema's content) Definition at line 778 of file queryschema.cpp. |
|
Sets alias for a table at position (within FROM section of the the query). Passing empty sting to alias clears alias for a given table (only for specified position). Definition at line 740 of file queryschema.cpp. |
|
Sets a WHERE expression exp. It will be owned by this query, so you can forget about it. Previously set WHERE expression will be deleted. You can pass 0 to remove expresssion. Definition at line 1026 of file queryschema.cpp. |
|
Definition at line 997 of file queryschema.cpp. |
|
Definition at line 773 of file queryschema.cpp. |
|
Definition at line 636 of file queryschema.cpp. |
|
Definition at line 690 of file queryschema.cpp. |
|
These checkings are performed e.g. by Connection::queryStatement() to construct a statement string maximally identical to originally defined query statement. -1 is returned if:
Definition at line 401 of file queryschema.cpp. |
|
Definition at line 704 of file queryschema.cpp. |
|
Definition at line 696 of file queryschema.cpp. |
|
Definition at line 714 of file queryschema.cpp. |
|
Definition at line 589 of file queryschema.cpp. |
|
Definition at line 1083 of file queryschema.cpp. |
Member Data Documentation
|
Automatically retrieves query schema via connection. Definition at line 502 of file queryschema.h. |
The documentation for this class was generated from the following files: