Sql: replace remaining uses of QLatin1String with QLatin1StringView
Task-number: QTBUG-98434 Change-Id: Ia621f9d937649dda41a7b0d13a61e6f1397f6dde Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
parent
128785d0fa
commit
fbbad06751
@ -802,7 +802,7 @@ bool QIBaseResultPrivate::writeArray(int column, const QList<QVariant> &list)
|
|||||||
|
|
||||||
if (list.size() > arraySize) {
|
if (list.size() > arraySize) {
|
||||||
error = "Array size mismatch: size of %1 is %2, size of provided list is %3"_L1;
|
error = "Array size mismatch: size of %1 is %2, size of provided list is %3"_L1;
|
||||||
error = error.arg(QLatin1String(sqlname)).arg(arraySize).arg(list.size());
|
error = error.arg(QLatin1StringView(sqlname)).arg(arraySize).arg(list.size());
|
||||||
q->setLastError(QSqlError(error, ""_L1, QSqlError::StatementError));
|
q->setLastError(QSqlError(error, ""_L1, QSqlError::StatementError));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -810,7 +810,7 @@ bool QIBaseResultPrivate::writeArray(int column, const QList<QVariant> &list)
|
|||||||
if (!createArrayBuffer(ba.data(), list,
|
if (!createArrayBuffer(ba.data(), list,
|
||||||
qIBaseTypeName(desc.array_desc_dtype, inda->sqlvar[column].sqlscale < 0),
|
qIBaseTypeName(desc.array_desc_dtype, inda->sqlvar[column].sqlscale < 0),
|
||||||
0, &desc, error)) {
|
0, &desc, error)) {
|
||||||
q->setLastError(QSqlError(error.arg(QLatin1String(sqlname)), ""_L1,
|
q->setLastError(QSqlError(error.arg(QLatin1StringView(sqlname)), ""_L1,
|
||||||
QSqlError::StatementError));
|
QSqlError::StatementError));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1376,14 +1376,14 @@ QStringList QMYSQLDriver::tables(QSql::TableType type) const
|
|||||||
QStringList tl;
|
QStringList tl;
|
||||||
QSqlQuery q(createResult());
|
QSqlQuery q(createResult());
|
||||||
if (type & QSql::Tables) {
|
if (type & QSql::Tables) {
|
||||||
QString sql = "select table_name from information_schema.tables where table_schema = '"_L1 + QLatin1String(d->mysql->db) + "' and table_type = 'BASE TABLE'"_L1;
|
QString sql = "select table_name from information_schema.tables where table_schema = '"_L1 + QLatin1StringView(d->mysql->db) + "' and table_type = 'BASE TABLE'"_L1;
|
||||||
q.exec(sql);
|
q.exec(sql);
|
||||||
|
|
||||||
while (q.next())
|
while (q.next())
|
||||||
tl.append(q.value(0).toString());
|
tl.append(q.value(0).toString());
|
||||||
}
|
}
|
||||||
if (type & QSql::Views) {
|
if (type & QSql::Views) {
|
||||||
QString sql = "select table_name from information_schema.tables where table_schema = '"_L1 + QLatin1String(d->mysql->db) + "' and table_type = 'VIEW'"_L1;
|
QString sql = "select table_name from information_schema.tables where table_schema = '"_L1 + QLatin1StringView(d->mysql->db) + "' and table_type = 'VIEW'"_L1;
|
||||||
q.exec(sql);
|
q.exec(sql);
|
||||||
|
|
||||||
while (q.next())
|
while (q.next())
|
||||||
|
@ -2470,14 +2470,14 @@ static QString make_where_clause(const QString &user, Expression e)
|
|||||||
static const char joinC[][4] = { "or" , "and" };
|
static const char joinC[][4] = { "or" , "and" };
|
||||||
static constexpr QLatin1Char bang[] = { u' ', u'!' };
|
static constexpr QLatin1Char bang[] = { u' ', u'!' };
|
||||||
|
|
||||||
const QLatin1String join(joinC[e]);
|
const QLatin1StringView join(joinC[e]);
|
||||||
|
|
||||||
QString result;
|
QString result;
|
||||||
result.reserve(sizeof sysUsers / sizeof *sysUsers *
|
result.reserve(sizeof sysUsers / sizeof *sysUsers *
|
||||||
// max-sizeof(owner != <sysuser> and )
|
// max-sizeof(owner != <sysuser> and )
|
||||||
(9 + sizeof *sysUsers + 5));
|
(9 + sizeof *sysUsers + 5));
|
||||||
for (const auto &sysUser : sysUsers) {
|
for (const auto &sysUser : sysUsers) {
|
||||||
const QLatin1String l1(sysUser);
|
const QLatin1StringView l1(sysUser);
|
||||||
if (l1 != user)
|
if (l1 != user)
|
||||||
result += "owner "_L1 + bang[e] + "= '"_L1 + l1 + "' "_L1 + join + u' ';
|
result += "owner "_L1 + bang[e] + "= '"_L1 + l1 + "' "_L1 + join + u' ';
|
||||||
}
|
}
|
||||||
|
@ -1521,7 +1521,7 @@ QString QPSQLDriver::formatValue(const QSqlField &field, bool trimStrings) const
|
|||||||
unsigned char *data = PQescapeBytea((const unsigned char*)ba.constData(), ba.size(), &len);
|
unsigned char *data = PQescapeBytea((const unsigned char*)ba.constData(), ba.size(), &len);
|
||||||
#endif
|
#endif
|
||||||
r += u'\'';
|
r += u'\'';
|
||||||
r += QLatin1String((const char*)data);
|
r += QLatin1StringView((const char*)data);
|
||||||
r += u'\'';
|
r += u'\'';
|
||||||
qPQfreemem(data);
|
qPQfreemem(data);
|
||||||
break;
|
break;
|
||||||
@ -1658,7 +1658,7 @@ void QPSQLDriver::_q_handleNotification()
|
|||||||
|
|
||||||
PGnotify *notify = nullptr;
|
PGnotify *notify = nullptr;
|
||||||
while ((notify = PQnotifies(d->connection)) != nullptr) {
|
while ((notify = PQnotifies(d->connection)) != nullptr) {
|
||||||
QString name(QLatin1String(notify->relname));
|
QString name(QLatin1StringView(notify->relname));
|
||||||
if (d->seid.contains(name)) {
|
if (d->seid.contains(name)) {
|
||||||
QString payload;
|
QString payload;
|
||||||
#if defined PG_VERSION_NUM && PG_VERSION_NUM-0 >= 70400
|
#if defined PG_VERSION_NUM && PG_VERSION_NUM-0 >= 70400
|
||||||
|
@ -114,15 +114,15 @@ public:
|
|||||||
static const char *defaultConnection;
|
static const char *defaultConnection;
|
||||||
|
|
||||||
static QSqlDatabase addDatabase(const QString& type,
|
static QSqlDatabase addDatabase(const QString& type,
|
||||||
const QString& connectionName = QLatin1String(defaultConnection));
|
const QString& connectionName = QLatin1StringView(defaultConnection));
|
||||||
static QSqlDatabase addDatabase(QSqlDriver* driver,
|
static QSqlDatabase addDatabase(QSqlDriver* driver,
|
||||||
const QString& connectionName = QLatin1String(defaultConnection));
|
const QString& connectionName = QLatin1StringView(defaultConnection));
|
||||||
static QSqlDatabase cloneDatabase(const QSqlDatabase &other, const QString& connectionName);
|
static QSqlDatabase cloneDatabase(const QSqlDatabase &other, const QString& connectionName);
|
||||||
static QSqlDatabase cloneDatabase(const QString &other, const QString& connectionName);
|
static QSqlDatabase cloneDatabase(const QString &other, const QString& connectionName);
|
||||||
static QSqlDatabase database(const QString& connectionName = QLatin1String(defaultConnection),
|
static QSqlDatabase database(const QString& connectionName = QLatin1StringView(defaultConnection),
|
||||||
bool open = true);
|
bool open = true);
|
||||||
static void removeDatabase(const QString& connectionName);
|
static void removeDatabase(const QString& connectionName);
|
||||||
static bool contains(const QString& connectionName = QLatin1String(defaultConnection));
|
static bool contains(const QString& connectionName = QLatin1StringView(defaultConnection));
|
||||||
static QStringList drivers();
|
static QStringList drivers();
|
||||||
static QStringList connectionNames();
|
static QStringList connectionNames();
|
||||||
static void registerSqlDriver(const QString &name, QSqlDriverCreatorBase *creator);
|
static void registerSqlDriver(const QString &name, QSqlDriverCreatorBase *creator);
|
||||||
|
@ -64,7 +64,7 @@ class QSqlNullResult : public QSqlResult
|
|||||||
public:
|
public:
|
||||||
inline explicit QSqlNullResult(const QSqlDriver* d): QSqlResult(d)
|
inline explicit QSqlNullResult(const QSqlDriver* d): QSqlResult(d)
|
||||||
{ QSqlResult::setLastError(
|
{ QSqlResult::setLastError(
|
||||||
QSqlError(QLatin1String("Driver not loaded"), QLatin1String("Driver not loaded"), QSqlError::ConnectionError)); }
|
QSqlError(QLatin1StringView("Driver not loaded"), QLatin1StringView("Driver not loaded"), QSqlError::ConnectionError)); }
|
||||||
protected:
|
protected:
|
||||||
inline QVariant data(int) override { return QVariant(); }
|
inline QVariant data(int) override { return QVariant(); }
|
||||||
inline bool reset (const QString&) override { return false; }
|
inline bool reset (const QString&) override { return false; }
|
||||||
@ -94,7 +94,7 @@ class QSqlNullDriver : public QSqlDriver
|
|||||||
public:
|
public:
|
||||||
inline QSqlNullDriver(): QSqlDriver()
|
inline QSqlNullDriver(): QSqlDriver()
|
||||||
{ QSqlDriver::setLastError(
|
{ QSqlDriver::setLastError(
|
||||||
QSqlError(QLatin1String("Driver not loaded"), QLatin1String("Driver not loaded"), QSqlError::ConnectionError)); }
|
QSqlError(QLatin1StringView("Driver not loaded"), QLatin1StringView("Driver not loaded"), QSqlError::ConnectionError)); }
|
||||||
inline bool hasFeature(DriverFeature) const override { return false; }
|
inline bool hasFeature(DriverFeature) const override { return false; }
|
||||||
inline bool open(const QString &, const QString &, const QString &, const QString &, int, const QString&) override
|
inline bool open(const QString &, const QString &, const QString &, const QString &, int, const QString&) override
|
||||||
{ return false; }
|
{ return false; }
|
||||||
|
@ -304,11 +304,13 @@ QSqlQuery& QSqlQuery::operator=(const QSqlQuery& other)
|
|||||||
static void qInit(QSqlQuery *q, const QString& query, const QSqlDatabase &db)
|
static void qInit(QSqlQuery *q, const QString& query, const QSqlDatabase &db)
|
||||||
{
|
{
|
||||||
QSqlDatabase database = db;
|
QSqlDatabase database = db;
|
||||||
if (!database.isValid())
|
if (!database.isValid()) {
|
||||||
database = QSqlDatabase::database(QLatin1String(QSqlDatabase::defaultConnection), false);
|
database =
|
||||||
if (database.isValid()) {
|
QSqlDatabase::database(QLatin1StringView(QSqlDatabase::defaultConnection), false);
|
||||||
*q = QSqlQuery(database.driver()->createResult());
|
|
||||||
}
|
}
|
||||||
|
if (database.isValid())
|
||||||
|
*q = QSqlQuery(database.driver()->createResult());
|
||||||
|
|
||||||
if (!query.isEmpty())
|
if (!query.isEmpty())
|
||||||
q->exec(query);
|
q->exec(query);
|
||||||
}
|
}
|
||||||
|
@ -90,22 +90,22 @@ class QSqlQueryModelSql
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// SQL keywords
|
// SQL keywords
|
||||||
inline const static QLatin1String as() { return QLatin1String("AS"); }
|
inline const static QLatin1StringView as() { return QLatin1StringView("AS"); }
|
||||||
inline const static QLatin1String asc() { return QLatin1String("ASC"); }
|
inline const static QLatin1StringView asc() { return QLatin1StringView("ASC"); }
|
||||||
inline const static QLatin1String comma() { return QLatin1String(","); }
|
inline const static QLatin1StringView comma() { return QLatin1StringView(","); }
|
||||||
inline const static QLatin1String desc() { return QLatin1String("DESC"); }
|
inline const static QLatin1StringView desc() { return QLatin1StringView("DESC"); }
|
||||||
inline const static QLatin1String eq() { return QLatin1String("="); }
|
inline const static QLatin1StringView eq() { return QLatin1StringView("="); }
|
||||||
// "and" is a C++ keyword
|
// "and" is a C++ keyword
|
||||||
inline const static QLatin1String et() { return QLatin1String("AND"); }
|
inline const static QLatin1StringView et() { return QLatin1StringView("AND"); }
|
||||||
inline const static QLatin1String from() { return QLatin1String("FROM"); }
|
inline const static QLatin1StringView from() { return QLatin1StringView("FROM"); }
|
||||||
inline const static QLatin1String leftJoin() { return QLatin1String("LEFT JOIN"); }
|
inline const static QLatin1StringView leftJoin() { return QLatin1StringView("LEFT JOIN"); }
|
||||||
inline const static QLatin1String on() { return QLatin1String("ON"); }
|
inline const static QLatin1StringView on() { return QLatin1StringView("ON"); }
|
||||||
inline const static QLatin1String orderBy() { return QLatin1String("ORDER BY"); }
|
inline const static QLatin1StringView orderBy() { return QLatin1StringView("ORDER BY"); }
|
||||||
inline const static QLatin1String parenClose() { return QLatin1String(")"); }
|
inline const static QLatin1StringView parenClose() { return QLatin1StringView(")"); }
|
||||||
inline const static QLatin1String parenOpen() { return QLatin1String("("); }
|
inline const static QLatin1StringView parenOpen() { return QLatin1StringView("("); }
|
||||||
inline const static QLatin1String select() { return QLatin1String("SELECT"); }
|
inline const static QLatin1StringView select() { return QLatin1StringView("SELECT"); }
|
||||||
inline const static QLatin1String sp() { return QLatin1String(" "); }
|
inline const static QLatin1StringView sp() { return QLatin1StringView(" "); }
|
||||||
inline const static QLatin1String where() { return QLatin1String("WHERE"); }
|
inline const static QLatin1StringView where() { return QLatin1StringView("WHERE"); }
|
||||||
|
|
||||||
// Build expressions based on key words
|
// Build expressions based on key words
|
||||||
inline const static QString as(const QString &a, const QString &b) { return b.isEmpty() ? a : concat(concat(a, as()), b); }
|
inline const static QString as(const QString &a, const QString &b) { return b.isEmpty() ? a : concat(concat(a, as()), b); }
|
||||||
|
Loading…
Reference in New Issue
Block a user