summaryrefslogtreecommitdiffstats
path: root/src/plugins/sqldrivers/oci/qsql_oci.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/sqldrivers/oci/qsql_oci.cpp')
-rw-r--r--src/plugins/sqldrivers/oci/qsql_oci.cpp23
1 files changed, 17 insertions, 6 deletions
diff --git a/src/plugins/sqldrivers/oci/qsql_oci.cpp b/src/plugins/sqldrivers/oci/qsql_oci.cpp
index 2b844218bf..1dc0c811db 100644
--- a/src/plugins/sqldrivers/oci/qsql_oci.cpp
+++ b/src/plugins/sqldrivers/oci/qsql_oci.cpp
@@ -19,7 +19,9 @@
#include <QtSql/private/qsqlcachedresult_p.h>
#include <QtSql/private/qsqldriver_p.h>
#include <qstringlist.h>
+#if QT_CONFIG(timezone)
#include <qtimezone.h>
+#endif
#include <qvariant.h>
#include <qvarlengtharray.h>
@@ -129,6 +131,15 @@ public:
~QOCIDateTime();
OCIDateTime *dateTime;
static QDateTime fromOCIDateTime(OCIEnv *env, OCIError *err, OCIDateTime *dt);
+ static QString toOffsetString(const QDateTime &dt)
+ {
+ const auto offset = dt.offsetFromUtc();
+ const auto offsetAbs = qAbs(offset) / 60;
+ return QString::asprintf("%c%02d:%02d",
+ offset >= 0 ? '+' : '-',
+ offsetAbs / 60,
+ offsetAbs % 60);
+ }
};
QOCIDateTime::QOCIDateTime(OCIEnv *env, OCIError *err, const QDateTime &dt)
@@ -138,8 +149,8 @@ QOCIDateTime::QOCIDateTime(OCIEnv *env, OCIError *err, const QDateTime &dt)
if (dt.isValid()) {
const QDate date = dt.date();
const QTime time = dt.time();
- // Zone in +hh:mm format (stripping UTC prefix from OffsetName)
- QString timeZone = dt.timeZone().displayName(dt, QTimeZone::OffsetName).mid(3);
+ // Zone in +hh:mm format
+ const QString timeZone = toOffsetString(dt);
const OraText *tz = reinterpret_cast<const OraText *>(timeZone.utf16());
OCIDateTimeConstruct(env, err, dateTime, date.year(), date.month(), date.day(), time.hour(),
time.minute(), time.second(), time.msec() * 1000000,
@@ -424,6 +435,7 @@ int QOCIResultPrivate::bindValue(OCIStmt *sql, OCIBind **hbnd, OCIError *err, in
break;
}
} // fall through for OUT values
+ Q_FALLTHROUGH();
default: {
if (val.typeId() >= QMetaType::User) {
if (val.canConvert<QOCIRowIdPointer>() && !isOutValue(pos)) {
@@ -2432,7 +2444,7 @@ static QString make_where_clause(const QString &user, Expression e)
"WMSYS",
};
static const char joinC[][4] = { "or" , "and" };
- static constexpr QLatin1Char bang[] = { u' ', u'!' };
+ static constexpr char16_t bang[] = { u' ', u'!' };
const QLatin1StringView join(joinC[e]);
@@ -2551,8 +2563,7 @@ QSqlRecord QOCIDriver::record(const QString& tablename) const
// eg. a sub-query on the sys.synonyms table
QString stmt("select column_name, data_type, data_length, "
"data_precision, data_scale, nullable, data_default%1"
- "from all_tab_columns a "
- "where a.table_name=%2"_L1);
+ "from all_tab_columns a "_L1);
if (d->serverVersion >= 9)
stmt = stmt.arg(", char_length "_L1);
else
@@ -2566,7 +2577,7 @@ QSqlRecord QOCIDriver::record(const QString& tablename) const
else
table = table.toUpper();
- tmpStmt = stmt.arg(u'\'' + table + u'\'');
+ tmpStmt = stmt + "where a.table_name='"_L1 + table + u'\'';
if (owner.isEmpty()) {
owner = d->user;
}