Revision 4efa3afe
Von Christian Ehringfeld vor etwa 9 Jahren hinzugefügt
samples/example/Example.pro | ||
---|---|---|
|
||
unix:!macx:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../build-EntityManager-Desktop-Debug -lCuteEntityManager
|
||
else:unix:!macx:CONFIG(release, release|debug): LIBS += -L$$PWD/../../../build-EntityManager-Desktop-Release/ -lCuteEntityManager
|
||
unix:INCLUDEPATH += $$PWD/../../src
|
||
unix:DEPENDPATH += $$PWD/../../src
|
||
CONFIG += c++14
|
||
QMAKE_CXXFLAGS += -std=c++14
|
||
|
||
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../build-EntityManager-Desktop-Release/release/ -lCuteEntityManager
|
||
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../build-EntityManager-Desktop-Debug/debug/ -lCuteEntityManager
|
||
|
||
win32:INCLUDEPATH += $$PWD/../../../build-EntityManager-Desktop-Debug/debug
|
||
win32:DEPENDPATH += $$PWD/../../../build-EntityManager-Desktop-Debug/debug
|
||
|
||
INCLUDEPATH += $$PWD/../../src
|
||
DEPENDPATH += $$PWD/../../src
|
||
|
||
... | ... | |
QMAKE_CXXFLAGS += -Wall -Wextra -Wmaybe-uninitialized -Wsuggest-final-types -Wsuggest-final-methods -Wsuggest-override -Wunsafe-loop-optimizations -pedantic -Wfloat-equal -Wundef -Wpointer-arith -Wcast-align -Wunreachable-code -O -Winit-self
|
||
}
|
||
|
||
win32-g++ {
|
||
CONFIG += c++11
|
||
QMAKE_CXXFLAGS += -std=c++11 -Wall
|
||
}
|
||
|
||
CONFIG(release, debug|release):DEFINES += QT_NO_DEBUG_OUTPUT
|
src/querybuilder.cpp | ||
---|---|---|
QVariant pk = attributes.value(primaryKey);
|
||
attributes.remove(primaryKey);
|
||
QSqlQuery q = this->database->getQuery("UPDATE " + this->schema->quoteTableName(
|
||
tableName) + " SET " + this->attributes(attributes) + " " + this->whereKeyword()
|
||
tableName) + " SET " + this->attributes(attributes,
|
||
false) + " " + this->whereKeyword()
|
||
+ " " +
|
||
this->schema->quoteColumnName(primaryKey) + " = " + this->placeHolder(
|
||
primaryKey) + ";");
|
||
... | ... | |
if (m.size() == 0 || (ignoreID && m.contains(primaryKey) && m.size() == 1)) {
|
||
return "";
|
||
}
|
||
return (withKeyword ? " WHERE " : "") + this->attributes(m, conjunction,
|
||
return (withKeyword ? " WHERE " : "") + this->attributes(m, true, conjunction,
|
||
ignoreID, primaryKey);
|
||
}
|
||
|
||
QString QueryBuilder::attributes(const QHash<QString, QVariant> &m,
|
||
QString QueryBuilder::attributes(const QHash<QString, QVariant> &m, bool select,
|
||
const QString &conjunction,
|
||
bool ignoreID, const QString &primaryKey) const {
|
||
QString rc = "";
|
||
... | ... | |
if (!rc.isEmpty()) {
|
||
rc += " " + conjunction + " ";
|
||
}
|
||
rc += this->schema->quoteColumnName(i.key()) + (i.value().isNull() ? " is null"
|
||
rc += this->schema->quoteColumnName(i.key()) + (i.value().isNull()
|
||
&& select ? " is null"
|
||
: "=" + this->placeHolder(i.key()));
|
||
}
|
||
}
|
src/querybuilder.h | ||
---|---|---|
const QString &conjunction,
|
||
bool ignoreID = false, const QString &primaryKey = "id",
|
||
bool withKeyword = true) const;
|
||
QString attributes(const QHash<QString, QVariant> &m,
|
||
QString attributes(const QHash<QString, QVariant> &m, bool select=true,
|
||
const QString &conjunction = ",",
|
||
bool ignoreID = false, const QString &primaryKey = "id") const;
|
||
QHash<QString, QVariant> saveAttributes(const QSharedPointer<Entity> &entity,
|
Auch abrufbar als: Unified diff
bugfix