KDb
KDbAlter.cpp
71 KDbAlterTableHandler::ChangeFieldPropertyAction& KDbAlterTableHandler::ActionBase::toChangeFieldPropertyAction()
92 KDbAlterTableHandler::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
221 QString KDbAlterTableHandler::ChangeFieldPropertyAction::debugString(const DebugOptions& debugOptions)
271 static void debugActionDict(KDbAlterTableHandler::ActionDict *dict, int fieldUID, bool simulate)
275 if (it != dict->constEnd() && dynamic_cast<KDbAlterTableHandler::FieldActionBase*>(it.value())) {
294 static 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
325 void 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;
394 bool KDbAlterTableHandler::ChangeFieldPropertyAction::shouldBeRemoved(ActionDictDict *fieldActions)
400 tristate KDbAlterTableHandler::ChangeFieldPropertyAction::updateTableSchema(KDbTableSchema* table, KDbField* field,
422 tristate KDbAlterTableHandler::ChangeFieldPropertyAction::execute(KDbConnection* conn, KDbTableSchema* table)
500 //! @todo sometimes add DataConversionRequired (e.g. when relationships require removing orphaned records) ?
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])
532 tristate KDbAlterTableHandler::RemoveFieldAction::updateTableSchema(KDbTableSchema* table, KDbField* field,
540 tristate KDbAlterTableHandler::RemoveFieldAction::execute(KDbConnection* conn, KDbTableSchema* table)
550 KDbAlterTableHandler::InsertFieldAction::InsertFieldAction(int fieldIndex, KDbField *field, int uid)
593 //! @todo sometimes add DataConversionRequired (e.g. when relationships require removing orphaned records) ?
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);
692 tristate KDbAlterTableHandler::InsertFieldAction::updateTableSchema(KDbTableSchema* table, KDbField* field,
703 tristate KDbAlterTableHandler::InsertFieldAction::execute(KDbConnection* conn, KDbTableSchema* table)
736 QString KDbAlterTableHandler::MoveFieldPositionAction::debugString(const DebugOptions& debugOptions)
746 void KDbAlterTableHandler::MoveFieldPositionAction::simplifyActions(ActionDictDict *fieldActions)
752 tristate KDbAlterTableHandler::MoveFieldPositionAction::execute(KDbConnection* conn, KDbTableSchema* table)
813 KDbTableSchema* 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)
bool isNull() const const
KDbUtils::AutodeletedHash< QByteArray, ActionBase * > ActionDict
For collecting actions related to a single field.
Definition: KDbAlter.h:141
const T value(const Key &key) const const
Abstract base class used for implementing all the AlterTable actions.
Definition: KDbAlter.h:158
CaseInsensitive
@ DropDestination
Drop destination table if exists.
Defines an action for removing a single table field.
Definition: KDbAlter.h:335
void updateAlteringRequirements() override
Definition: KDbAlter.cpp:730
bool showUID
true if UID should be added to the action debug string (the default)
Definition: KDbAlter.h:181
QByteArray toLatin1() const const
void updateAlteringRequirements() override
Definition: KDbAlter.cpp:498
Abstract base class used for implementing table field-related actions.
Definition: KDbAlter.h:248
void simplifyActions(ActionDictDict *fieldActions) override
Definition: KDbAlter.cpp:624
bool shouldBeRemoved(ActionDictDict *fieldActions) override
Definition: KDbAlter.cpp:394
void simplifyActions(ActionDictDict *fieldActions) override
Definition: KDbAlter.cpp:325
KDB_EXPORT QVariant notEmptyValueForFieldType(KDbField::Type type)
Used in KDb::notEmptyValueForFieldType()
Definition: KDb.cpp:1275
@ ExtendedSchemaAlteringRequired
Definition: KDbAlter.h:135
KDB_EXPORT QVariant emptyValueForFieldType(KDbField::Type type)
Used in KDb::emptyValueForFieldType()
Definition: KDb.cpp:1222
bool onlyComputeRequirements
Definition: KDbAlter.h:478
Defines an action for inserting a single table field.
Definition: KDbAlter.h:360
QHash::iterator insert(const Key &key, const T &value)
Q_GLOBAL_STATIC(Internal::StaticControl, s_instance) class ControlPrivate
QStringList types(Mode mode=Writing)
KDB_EXPORT bool setFieldProperty(KDbField *field, const QByteArray &propertyName, const QVariant &value)
Definition: KDb.cpp:981
T value(int i) const const
tristate execute(KDbConnection *conn, KDbTableSchema *table) override
Performs physical execution of this action.
Definition: KDbAlter.cpp:703
T take(const Key &key)
QString * debugString
Definition: KDbAlter.h:469
KDbTableSchema * execute(const QString &tableName, ExecutionArguments *args)
Definition: KDbAlter.cpp:813
KDbAlterTableHandler & operator<<(ActionBase *action)
Definition: KDbAlter.cpp:778
QHash::const_iterator constBegin() const const
QHash::const_iterator constEnd() const const
void debug(const DebugOptions &debugOptions=DebugOptions())
Definition: KDbAlter.cpp:99
static int alteringTypeForProperty(const QByteArray &propertyName)
Definition: KDbAlter.cpp:181
const T & at(int i) const const
bool isEmpty() const const
bool removeField(KDbField *field) override
Definition: KDbTableSchema.cpp:293
bool insertField(int index, KDbField *field) override
Definition: KDbTableSchema.cpp:243
void setActions(const ActionList &actions)
Definition: KDbAlter.cpp:799
KDB_EXPORT bool setFieldProperties(KDbField *field, const QMap< QByteArray, QVariant > &values)
Definition: KDb.cpp:833
void debug()
Displays debug information about all actions collected by the handler.
Definition: KDbAlter.cpp:805
bool showFieldDebug
true if the field associated with the action (if exists) should be appended to the debug string (defa...
Definition: KDbAlter.h:185
3-state logical type with three values: true, false and cancelled and convenient operators.
Definition: KDbTristate.h:100
tristate execute(KDbConnection *conn, KDbTableSchema *table) override
Performs physical execution of this action.
Definition: KDbAlter.cpp:422
tristate execute(KDbConnection *conn, KDbTableSchema *table) override
Performs physical execution of this action.
Definition: KDbAlter.cpp:752
void updateAlteringRequirements() override
Definition: KDbAlter.cpp:591
QString arg(qlonglong a, int fieldWidth, int base, QChar fillChar) const const
int remove(const Key &key)
QString fromLatin1(const char *str, int size)
KDB_EXPORT QString temporaryTableName(KDbConnection *conn, const QString &baseName)
Definition: KDb.cpp:2055
QSet::iterator insert(const T &value)
KDB_EXPORT bool isExtendedTableFieldProperty(const QByteArray &propertyName)
for isExtendedTableProperty()
Definition: KDb.cpp:954
bool renameField(const QString &oldName, const QString &newName)
Definition: KDbFieldList.cpp:141
int compare(const QString &other, Qt::CaseSensitivity cs) const const
Arguments for KDbAlterTableHandler::execute().
Definition: KDbAlter.h:458
int count(const Key &key) const const
Provides database connection, allowing queries and data modification.
Definition: KDbConnection.h:51
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:540
@ MainSchemaAlteringRequired
Definition: KDbAlter.h:129
QVector< V > values(const QMultiHash< K, V > &c)
Controls debug options for actions. Used in debugString() and debug().
Definition: KDbAlter.h:175
QString & append(QChar ch)
bool isEmpty() const const
void simplifyActions(ActionDictDict *fieldActions) override
Definition: KDbAlter.cpp:521
void simplifyActions(ActionDictDict *fieldActions) override
Definition: KDbAlter.cpp:746
Definition: KDbTableSchema.h:37
QString toString() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Thu Dec 7 2023 04:09:06 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2023 The KDE developers.
Generated on Thu Dec 7 2023 04:09:06 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.