summaryrefslogtreecommitdiffstats
path: root/src/plugins/sqldrivers/ibase
diff options
context:
space:
mode:
authorAndy Shaw <andy.shaw@qt.io>2020-08-02 14:54:28 +0200
committerAndy Shaw <andy.shaw@qt.io>2020-09-11 07:32:42 +0200
commit37e7c3c11698812f07d8b78c90d0adcffd1d0d33 (patch)
treee8e10182f6ca5fc7905800e970fd5be3c2b95a85 /src/plugins/sqldrivers/ibase
parent37f4c6fbc28617fdd3343033c6f926ec2263fce2 (diff)
Interbase: Add support for the boolean type
This is added to Interbase in v7 and Firebird in v3 which has been available for sometime now. This means the minimum supported for Interbase is now v7. [ChangeLog][QtSQL][Interbase] The minimum required version for Interbase is now v7. Fixes: QTBUG-83401 Change-Id: I9927fd962f25c935be8ed5d2b7c76c00fb88cd8c Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
Diffstat (limited to 'src/plugins/sqldrivers/ibase')
-rw-r--r--src/plugins/sqldrivers/ibase/qsql_ibase.cpp23
1 files changed, 22 insertions, 1 deletions
diff --git a/src/plugins/sqldrivers/ibase/qsql_ibase.cpp b/src/plugins/sqldrivers/ibase/qsql_ibase.cpp
index 1754492fe7..6b7ee8f133 100644
--- a/src/plugins/sqldrivers/ibase/qsql_ibase.cpp
+++ b/src/plugins/sqldrivers/ibase/qsql_ibase.cpp
@@ -64,6 +64,11 @@ QT_BEGIN_NAMESPACE
#define SQLDA_CURRENT_VERSION SQLDA_VERSION1
#endif
+// Firebird uses blr_bool and not blr_boolean_dtype which is what Interbase uses
+#ifndef blr_boolean_dtype
+#define blr_boolean_dtype blr_bool
+#endif
+
enum { QIBaseChunkSize = SHRT_MAX / 2 };
static bool getIBaseError(QString& msg, const ISC_STATUS* status, ISC_LONG &sqlcode)
@@ -117,6 +122,7 @@ static void initDA(XSQLDA *sqlda)
case SQL_TYPE_DATE:
case SQL_TEXT:
case SQL_BLOB:
+ case SQL_BOOLEAN:
sqlda->sqlvar[i].sqldata = new char[sqlda->sqlvar[i].sqllen];
break;
case SQL_ARRAY:
@@ -179,6 +185,8 @@ static QVariant::Type qIBaseTypeName(int iType, bool hasScale)
case blr_d_float:
case blr_double:
return QVariant::Double;
+ case blr_boolean_dtype:
+ return QVariant::Bool;
}
qWarning("qIBaseTypeName: unknown datatype: %d", iType);
return QVariant::Invalid;
@@ -208,6 +216,8 @@ static QVariant::Type qIBaseTypeName2(int iType, bool hasScale)
return QVariant::List;
case SQL_BLOB:
return QVariant::ByteArray;
+ case SQL_BOOLEAN:
+ return QVariant::Bool;
default:
return QVariant::Invalid;
}
@@ -378,7 +388,6 @@ public:
bool writeBlob(int i, const QByteArray &ba);
QVariant fetchArray(int pos, ISC_QUAD *arr);
bool writeArray(int i, const QList<QVariant> &list);
-
public:
ISC_STATUS status[20];
isc_tr_handle trans;
@@ -549,6 +558,9 @@ static char* readArrayBuffer(QList<QVariant>& list, char *buffer, short curDim,
buffer += sizeof(ISC_DATE);
}
break;
+ case blr_boolean_dtype:
+ valList = toList<bool>(&buffer, numElements[dim]);
+ break;
}
}
if (dim > 0)
@@ -739,6 +751,9 @@ static char* createArrayBuffer(char *buffer, const QList<QVariant> &list,
buffer += sizeof(ISC_TIMESTAMP);
}
break;
+ case QVariant::Bool:
+ buffer = fillList<bool>(buffer, list);
+ break;
default:
break;
}
@@ -1032,6 +1047,9 @@ bool QIBaseResult::exec()
case SQL_ARRAY:
ok &= d->writeArray(para, val.toList());
break;
+ case SQL_BOOLEAN:
+ *((bool*)d->inda->sqlvar[para].sqldata) = val.toBool();
+ break;
default:
qWarning("QIBaseResult::exec: Unknown datatype %d",
d->inda->sqlvar[para].sqltype & ~1);
@@ -1184,6 +1202,9 @@ bool QIBaseResult::gotoNext(QSqlCachedResult::ValueCache& row, int rowIdx)
case SQL_ARRAY:
row[idx] = d->fetchArray(i, (ISC_QUAD*)buf);
break;
+ case SQL_BOOLEAN:
+ row[idx] = QVariant(bool((*(bool*)buf)));
+ break;
default:
// unknown type - don't even try to fetch
row[idx] = QVariant();