KDb
KDbAlter.cpp
71KDbAlterTableHandler::ChangeFieldPropertyAction& KDbAlterTableHandler::ActionBase::toChangeFieldPropertyAction()
92KDbAlterTableHandler::MoveFieldPositionAction& KDbAlterTableHandler::ActionBase::toMoveFieldPositionAction()
160 I2("unique", PhysicalAlteringRequired, DataConversionRequired); // we may want to add an Index here
161 I2("notNull", PhysicalAlteringRequired, DataConversionRequired); // we may want to add an Index here
164 I2("autoIncrement", PhysicalAlteringRequired, DataConversionRequired); // data conversion may be hard here
165 I2("indexed", PhysicalAlteringRequired, DataConversionRequired); // we may want to add an Index here
221QString KDbAlterTableHandler::ChangeFieldPropertyAction::debugString(const DebugOptions& debugOptions)
275 if (it != dict->constEnd() && dynamic_cast<KDbAlterTableHandler::FieldActionBase*>(it.value())) {
294static void debugFieldActions(const KDbAlterTableHandler::ActionDictDict &fieldActions, bool simulate)
300 for (KDbAlterTableHandler::ActionDictDictConstIterator it(fieldActions.constBegin()); it != fieldActions.constEnd(); ++it) {
306 Legend: A,B==fields, P==property, [....]==action, (..,..,..) group of actions, <...> internal operation.
323 do not add [change property in field A] because it will be removed anyway or the property will change
325void KDbAlterTableHandler::ChangeFieldPropertyAction::simplifyActions(ActionDictDict *fieldActions)
339 newRenameAction->m_newValue = dynamic_cast<ChangeFieldPropertyAction*>(renameActionLikeThis)->m_newValue;
348 ActionBase *removeActionForThisField = actionsLikeThis ? actionsLikeThis->value(":remove:") : nullptr;
374 ActionBase *removeActionForThisField = actionsLikeThis ? actionsLikeThis->value(":remove:") : nullptr;
394bool KDbAlterTableHandler::ChangeFieldPropertyAction::shouldBeRemoved(ActionDictDict *fieldActions)
400tristate KDbAlterTableHandler::ChangeFieldPropertyAction::updateTableSchema(KDbTableSchema* table, KDbField* field,
516 Legend: A,B==objects, P==property, [....]==action, (..,..,..) group of actions, <...> internal operation.
517 Preconditions: we assume there cannot be such case encountered: ([remove A], [do something related on A])
532tristate KDbAlterTableHandler::RemoveFieldAction::updateTableSchema(KDbTableSchema* table, KDbField* field,
550KDbAlterTableHandler::InsertFieldAction::InsertFieldAction(int fieldIndex, KDbField *field, int uid)
613 Legend: A,B==fields, P==property, [....]==action, (..,..,..) group of actions, <...> internal operation.
629 ActionBase *removeActionForThisField = actionsForThisField ? actionsForThisField->value(":remove:") : nullptr;
639 ActionDict *newActionsForThisField = new ActionDict(); // this will replace actionsForThisField after the loop
640 QSet<ActionBase*> actionsToDelete; // used to collect actions taht we soon delete but cannot delete in the loop below
641 for (ActionDictConstIterator it(actionsForThisField->constBegin()); it != actionsForThisField->constEnd();++it) {
642 ChangeFieldPropertyAction* changePropertyAction = dynamic_cast<ChangeFieldPropertyAction*>(it.value());
648 values.insert(changePropertyAction->propertyName().toLatin1(), changePropertyAction->newValue());
676 QLatin1String("** Failed to set properties for field ") + KDbUtils::debugString<KDbField>(*field()), 0);
736QString KDbAlterTableHandler::MoveFieldPositionAction::debugString(const DebugOptions& debugOptions)
746void KDbAlterTableHandler::MoveFieldPositionAction::simplifyActions(ActionDictDict *fieldActions)
813KDbTableSchema* KDbAlterTableHandler::execute(const QString& tableName, ExecutionArguments* args)
892 for (ActionDictDictConstIterator it(fieldActions.constBegin()); it != fieldActions.constEnd(); ++it) {
910 QString dbg = QString::fromLatin1("** Overall altering requirements: %1").arg(args->requirements);
947 KDbTableSchema *newTable = recreateTable ? new KDbTableSchema(*oldTable, false/*!copy id*/) : oldTable;
1038 KDbEscapedString sql = KDbEscapedString("INSERT INTO %1 (").arg(d->conn->escapeIdentifier(newTable->name()));
1045 const KDbField::Type type = f->type(); // cache: evaluating type of expressions can be expensive
1098 KDbConnection::AlterTableNameOption::Default | KDbConnection::AlterTableNameOption::DropDestination))
1109 if ((MainSchemaAlteringRequired & args->requirements) && !fieldsWithChangedMainSchema.isEmpty()) {
1128/*KDbTableSchema* KDbAlterTableHandler::execute(const QString& tableName, tristate &result, bool simulate)
1133tristate KDbAlterTableHandler::simulateExecution(const QString& tableName, QString& debugString)
Controls debug options for actions. Used in debugString() and debug().
Definition KDbAlter.h:176
bool showFieldDebug
true if the field associated with the action (if exists) should be appended to the debug string (defa...
Definition KDbAlter.h:185
bool showUID
true if UID should be added to the action debug string (the default)
Definition KDbAlter.h:181
Abstract base class used for implementing all the AlterTable actions.
Definition KDbAlter.h:159
void debug(const DebugOptions &debugOptions=DebugOptions())
Definition KDbAlter.cpp:99
tristate execute(KDbConnection *conn, KDbTableSchema *table) override
Performs physical execution of this action.
Definition KDbAlter.cpp:422
bool shouldBeRemoved(ActionDictDict *fieldActions) override
Definition KDbAlter.cpp:394
void simplifyActions(ActionDictDict *fieldActions) override
Definition KDbAlter.cpp:325
Arguments for KDbAlterTableHandler::execute().
Definition KDbAlter.h:459
bool onlyComputeRequirements
Definition KDbAlter.h:478
Abstract base class used for implementing table field-related actions.
Definition KDbAlter.h:249
Defines an action for inserting a single table field.
Definition KDbAlter.h:361
void updateAlteringRequirements() override
Definition KDbAlter.cpp:591
void simplifyActions(ActionDictDict *fieldActions) override
Definition KDbAlter.cpp:624
tristate execute(KDbConnection *conn, KDbTableSchema *table) override
Performs physical execution of this action.
Definition KDbAlter.cpp:703
tristate updateTableSchema(KDbTableSchema *table, KDbField *field, QHash< QString, QString > *fieldHash) override
Definition KDbAlter.cpp:692
tristate execute(KDbConnection *conn, KDbTableSchema *table) override
Performs physical execution of this action.
Definition KDbAlter.cpp:752
void updateAlteringRequirements() override
Definition KDbAlter.cpp:730
void simplifyActions(ActionDictDict *fieldActions) override
Definition KDbAlter.cpp:746
Defines an action for removing a single table field.
Definition KDbAlter.h:336
void updateAlteringRequirements() override
Definition KDbAlter.cpp:498
tristate execute(KDbConnection *conn, KDbTableSchema *table) override
Performs physical execution of this action.
Definition KDbAlter.cpp:540
void simplifyActions(ActionDictDict *fieldActions) override
Definition KDbAlter.cpp:521
void setActions(const ActionList &actions)
Definition KDbAlter.cpp:799
void debug()
Displays debug information about all actions collected by the handler.
Definition KDbAlter.cpp:805
@ MainSchemaAlteringRequired
Definition KDbAlter.h:129
@ ExtendedSchemaAlteringRequired
Definition KDbAlter.h:135
KDbTableSchema * execute(const QString &tableName, ExecutionArguments *args)
Definition KDbAlter.cpp:813
KDbAlterTableHandler & operator<<(ActionBase *action)
Definition KDbAlter.cpp:778
static int alteringTypeForProperty(const QByteArray &propertyName)
Definition KDbAlter.cpp:181
KDbUtils::AutodeletedHash< QByteArray, ActionBase * > ActionDict
For collecting actions related to a single field.
Definition KDbAlter.h:143
Provides database connection, allowing queries and data modification.
Definition KDbConnection.h:52
bool storeMainFieldSchema(KDbField *field)
Definition KDbConnection.cpp:1363
bool executeSql(const KDbEscapedString &sql)
Executes a new native (raw, backend-specific) SQL query.
Definition KDbConnection.cpp:1286
virtual QString escapeIdentifier(const QString &id) const
Identifier escaping function in the associated KDbDriver.
Definition KDbConnection.cpp:3044
bool createTable(KDbTableSchema *tableSchema, CreateTableOptions options=CreateTableOption::Default)
Creates a new table.
Definition KDbConnection.cpp:1397
KDbTableSchema * tableSchema(int tableId)
Definition KDbConnection.cpp:2919
bool storeExtendedTableSchemaData(KDbTableSchema *tableSchema)
Definition KDbConnection.cpp:2680
@ DropDestination
Drop destination table if exists.
bool alterTableName(KDbTableSchema *tableSchema, const QString &newName, AlterTableNameOptions options=AlterTableNameOption::Default)
Alters name of table.
Definition KDbConnection.cpp:1700
virtual KDbEscapedString valueToSql(KDbField::Type ftype, const QVariant &v) const
Definition KDbDriver.cpp:246
bool renameField(const QString &oldName, const QString &newName)
Definition KDbFieldList.cpp:141
Definition KDbTableSchema.h:38
bool removeField(KDbField *field) override
Definition KDbTableSchema.cpp:293
bool insertField(int index, KDbField *field) override
Definition KDbTableSchema.cpp:243
3-state logical type with three values: true, false and cancelled and convenient operators.
Definition KDbTristate.h:101
KDB_EXPORT bool isExtendedTableFieldProperty(const QByteArray &propertyName)
for isExtendedTableProperty()
Definition KDb.cpp:954
KDB_EXPORT bool setFieldProperties(KDbField *field, const QMap< QByteArray, QVariant > &values)
Definition KDb.cpp:833
KDB_EXPORT QVariant notEmptyValueForFieldType(KDbField::Type type)
Used in KDb::notEmptyValueForFieldType()
Definition KDb.cpp:1275
KDB_EXPORT bool setFieldProperty(KDbField *field, const QByteArray &propertyName, const QVariant &value)
Definition KDb.cpp:981
KDB_EXPORT QVariant emptyValueForFieldType(KDbField::Type type)
Used in KDb::emptyValueForFieldType()
Definition KDb.cpp:1222
KDB_EXPORT QString temporaryTableName(KDbConnection *conn, const QString &baseName)
const_iterator constBegin() const const
const_iterator constEnd() const const
qsizetype count() const const
iterator insert(const Key &key, const T &value)
bool remove(const Key &key)
T take(const Key &key)
T value(const Key &key) const const
void append(QList< T > &&value)
const_reference at(qsizetype i) const const
void clear()
qsizetype count() const const
void removeAt(qsizetype i)
T value(qsizetype i) const const
iterator insert(const Key &key, const T &value)
bool isEmpty() const const
iterator insert(const T &value)
bool isEmpty() const const
QString & append(QChar ch)
QString arg(Args &&... args) const const
int compare(QLatin1StringView s1, const QString &s2, Qt::CaseSensitivity cs)
QString fromLatin1(QByteArrayView str)
bool isEmpty() const const
QByteArray toLatin1() const const
CaseInsensitive
bool isNull() const const
QString toString() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:00:42 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:00:42 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.