QtSql: Disambiguate typedefs
They cause clashes in CMake Unity (Jumbo) builds. Task-number: QTBUG-109394 Pick-to: 6.5 6.4 6.2 Change-Id: I3f94044671cdbd0a1bb0964bf291e36508223b50 Reviewed-by: Andy Shaw <andy.shaw@qt.io>
This commit is contained in:
parent
73e7ffb2fd
commit
d9d74723cc
@ -27,7 +27,7 @@ public:
|
||||
inline const static QString relTablePrefix(int i) { return QString::number(i).prepend("relTblAl_"_L1); }
|
||||
};
|
||||
|
||||
typedef QSqlRelationalTableModelSql Sql;
|
||||
using SqlrTm = QSqlRelationalTableModelSql;
|
||||
|
||||
/*!
|
||||
\class QSqlRelation
|
||||
@ -540,12 +540,12 @@ QString QSqlRelationalTableModel::selectStatement() const
|
||||
|
||||
QString fList;
|
||||
QString conditions;
|
||||
QString from = Sql::from(tableName());
|
||||
QString from = SqlrTm::from(tableName());
|
||||
for (int i = 0; i < d->baseRec.count(); ++i) {
|
||||
QSqlRelation relation = d->relations.value(i).rel;
|
||||
const QString tableField = d->fullyQualifiedFieldName(tableName(), d->db.driver()->escapeIdentifier(d->baseRec.fieldName(i), QSqlDriver::FieldName));
|
||||
if (relation.isValid()) {
|
||||
const QString relTableAlias = Sql::relTablePrefix(i);
|
||||
const QString relTableAlias = SqlrTm::relTablePrefix(i);
|
||||
QString displayTableField = d->fullyQualifiedFieldName(relTableAlias, relation.displayColumn());
|
||||
|
||||
// Duplicate field names must be aliased
|
||||
@ -559,36 +559,36 @@ QString QSqlRelationalTableModel::selectStatement() const
|
||||
QString alias = QString::fromLatin1("%1_%2_%3")
|
||||
.arg(relTableName, displayColumn, QString::number(fieldNames.value(fieldList[i])));
|
||||
alias.truncate(d->db.driver()->maximumIdentifierLength(QSqlDriver::FieldName));
|
||||
displayTableField = Sql::as(displayTableField, alias);
|
||||
displayTableField = SqlrTm::as(displayTableField, alias);
|
||||
--fieldNames[fieldList[i]];
|
||||
}
|
||||
|
||||
fList = Sql::comma(fList, displayTableField);
|
||||
fList = SqlrTm::comma(fList, displayTableField);
|
||||
|
||||
// Join related table
|
||||
const QString tblexpr = Sql::concat(relation.tableName(), relTableAlias);
|
||||
const QString tblexpr = SqlrTm::concat(relation.tableName(), relTableAlias);
|
||||
const QString relTableField = d->fullyQualifiedFieldName(relTableAlias, relation.indexColumn());
|
||||
const QString cond = Sql::eq(tableField, relTableField);
|
||||
const QString cond = SqlrTm::eq(tableField, relTableField);
|
||||
if (d->joinMode == QSqlRelationalTableModel::InnerJoin) {
|
||||
// FIXME: InnerJoin code is known to be broken.
|
||||
// Use LeftJoin mode if you want correct behavior.
|
||||
from = Sql::comma(from, tblexpr);
|
||||
conditions = Sql::et(conditions, cond);
|
||||
from = SqlrTm::comma(from, tblexpr);
|
||||
conditions = SqlrTm::et(conditions, cond);
|
||||
} else {
|
||||
from = Sql::concat(from, Sql::leftJoin(tblexpr));
|
||||
from = Sql::concat(from, Sql::on(cond));
|
||||
from = SqlrTm::concat(from, SqlrTm::leftJoin(tblexpr));
|
||||
from = SqlrTm::concat(from, SqlrTm::on(cond));
|
||||
}
|
||||
} else {
|
||||
fList = Sql::comma(fList, tableField);
|
||||
fList = SqlrTm::comma(fList, tableField);
|
||||
}
|
||||
}
|
||||
|
||||
if (fList.isEmpty())
|
||||
return QString();
|
||||
|
||||
const QString stmt = Sql::concat(Sql::select(fList), from);
|
||||
const QString where = Sql::where(Sql::et(Sql::paren(conditions), Sql::paren(filter())));
|
||||
return Sql::concat(Sql::concat(stmt, where), orderByClause());
|
||||
const QString stmt = SqlrTm::concat(SqlrTm::select(fList), from);
|
||||
const QString where = SqlrTm::where(SqlrTm::et(SqlrTm::paren(conditions), SqlrTm::paren(filter())));
|
||||
return SqlrTm::concat(SqlrTm::concat(stmt, where), orderByClause());
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -732,9 +732,9 @@ QString QSqlRelationalTableModel::orderByClause() const
|
||||
if (!rel.isValid())
|
||||
return QSqlTableModel::orderByClause();
|
||||
|
||||
QString f = d->fullyQualifiedFieldName(Sql::relTablePrefix(d->sortColumn), rel.displayColumn());
|
||||
f = d->sortOrder == Qt::AscendingOrder ? Sql::asc(f) : Sql::desc(f);
|
||||
return Sql::orderBy(f);
|
||||
QString f = d->fullyQualifiedFieldName(SqlrTm::relTablePrefix(d->sortColumn), rel.displayColumn());
|
||||
f = d->sortOrder == Qt::AscendingOrder ? SqlrTm::asc(f) : SqlrTm::desc(f);
|
||||
return SqlrTm::orderBy(f);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -19,7 +19,7 @@ QT_BEGIN_NAMESPACE
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
typedef QSqlTableModelSql Sql;
|
||||
using SqlTm = QSqlTableModelSql;
|
||||
|
||||
QSqlTableModelPrivate::~QSqlTableModelPrivate()
|
||||
{
|
||||
@ -342,7 +342,7 @@ bool QSqlTableModel::select()
|
||||
|
||||
d->clearCache();
|
||||
|
||||
setQuery(query, d->db);
|
||||
this->QSqlQueryModel::setQuery(query, d->db);
|
||||
|
||||
if (!d->query.isActive() || lastError().isValid()) {
|
||||
// something went wrong - revert to non-select state
|
||||
@ -379,7 +379,7 @@ bool QSqlTableModel::selectRow(int row)
|
||||
d->tableName,
|
||||
primaryValues(row),
|
||||
false);
|
||||
static const QString wh = Sql::where() + Sql::sp();
|
||||
static const QString wh = SqlTm::where() + SqlTm::sp();
|
||||
if (d->filter.startsWith(wh, Qt::CaseInsensitive))
|
||||
d->filter.remove(0, wh.size());
|
||||
|
||||
@ -614,7 +614,7 @@ bool QSqlTableModel::updateRowInTable(int row, const QSqlRecord &values)
|
||||
return false;
|
||||
}
|
||||
|
||||
return d->exec(Sql::concat(stmt, where), prepStatement, rec, whereValues);
|
||||
return d->exec(SqlTm::concat(stmt, where), prepStatement, rec, whereValues);
|
||||
}
|
||||
|
||||
|
||||
@ -682,7 +682,7 @@ bool QSqlTableModel::deleteRowFromTable(int row)
|
||||
return false;
|
||||
}
|
||||
|
||||
return d->exec(Sql::concat(stmt, where), prepStatement, QSqlRecord() /* no new values */, whereValues);
|
||||
return d->exec(SqlTm::concat(stmt, where), prepStatement, QSqlRecord() /* no new values */, whereValues);
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -954,8 +954,8 @@ QString QSqlTableModel::orderByClause() const
|
||||
QString field = d->db.driver()->escapeIdentifier(d->tableName, QSqlDriver::TableName)
|
||||
+ u'.'
|
||||
+ d->db.driver()->escapeIdentifier(f.name(), QSqlDriver::FieldName);
|
||||
field = d->sortOrder == Qt::AscendingOrder ? Sql::asc(field) : Sql::desc(field);
|
||||
return Sql::orderBy(field);
|
||||
field = d->sortOrder == Qt::AscendingOrder ? SqlTm::asc(field) : SqlTm::desc(field);
|
||||
return SqlTm::orderBy(field);
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -997,7 +997,7 @@ QString QSqlTableModel::selectStatement() const
|
||||
QString(), QSqlError::StatementError);
|
||||
return stmt;
|
||||
}
|
||||
return Sql::concat(Sql::concat(stmt, Sql::where(d->filter)), orderByClause());
|
||||
return SqlTm::concat(SqlTm::concat(stmt, SqlTm::where(d->filter)), orderByClause());
|
||||
}
|
||||
|
||||
/*!
|
||||
|
Loading…
Reference in New Issue
Block a user