Skip to content

Commit

Permalink
ibase: Fix the compilation and include it again so it can be detected
Browse files Browse the repository at this point in the history
Change-Id: I38721155f090173862da8beab8cb04b2e015dcff
Reviewed-by: Christian Ehrlicher <[email protected]>
  • Loading branch information
AndyShawQt committed Jan 26, 2021
1 parent fe7cbf8 commit feb2045
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 19 deletions.
51 changes: 51 additions & 0 deletions cmake/FindInterbase.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#.rst:
# FindInterbase
# ---------
#
# Try to locate the Interbase client library.
# If found, this will define the following variables:
#
# ``Interbase_FOUND``
# True if the Interbase library is available
# ``Interbase_INCLUDE_DIR``
# The Interbase include directories
# ``Interbase_LIBRARY``
# The Interbase libraries for linking
#
# If ``Interbase_FOUND`` is TRUE, it will also define the following
# imported target:
#
# ``Interbase::Interbase``
# The Interbase client library

find_path(Interbase_INCLUDE_DIR
NAMES ibase.h
HINTS ${Interbase_INCLUDEDIR}
)

find_library(Interbase_LIBRARY
NAMES firebase_ms fbclient gds
HINTS ${Interbase_LIBDIR}
)

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Interbase DEFAULT_MSG Interbase_LIBRARY Interbase_INCLUDE_DIR)

if(Interbase_FOUND)
set(Interbase_INCLUDE_DIRS "${Interbase_INCLUDE_DIR}")
set(Interbase_LIBRARIES "${Interbase_LIBRARY}")
if(NOT TARGET Interbase::Interbase)
add_library(Interbase::Interbase UNKNOWN IMPORTED)
set_target_properties(Interbase::Interbase PROPERTIES
IMPORTED_LOCATION "${Interbase_LIBRARIES}"
INTERFACE_INCLUDE_DIRECTORIES "${Interbase_INCLUDE_DIRS};")
endif()
endif()

mark_as_advanced(Interbase_INCLUDE_DIR Interbase_LIBRARY)

include(FeatureSummary)
set_package_properties(Interbase PROPERTIES
URL "https://www.embarcadero.com/products/interbase"
DESCRIPTION "Interbase client library")

2 changes: 1 addition & 1 deletion src/plugins/sqldrivers/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ if(QT_FEATURE_sql_sqlite2)
endif()

if(QT_FEATURE_sql_ibase)
# TODO add_subdirectory(ibase)
add_subdirectory(ibase)
endif()

if(NOT CMAKE_PROJECT_NAME STREQUAL "QtBase" AND NOT CMAKE_PROJECT_NAME STREQUAL "Qt")
Expand Down
3 changes: 2 additions & 1 deletion src/plugins/sqldrivers/configure.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ qt_find_package(PostgreSQL PROVIDED_TARGETS PostgreSQL::PostgreSQL MODULE_NAME s
qt_find_package(Oracle PROVIDED_TARGETS Oracle::OCI MODULE_NAME sqldrivers QMAKE_LIB oci)
qt_find_package(ODBC PROVIDED_TARGETS ODBC::ODBC MODULE_NAME sqldrivers QMAKE_LIB odbc)
qt_find_package(SQLite3 PROVIDED_TARGETS SQLite::SQLite3 MODULE_NAME sqldrivers QMAKE_LIB sqlite3)
qt_find_package(Interbase PROVIDED_TARGETS Interbase::Interbase MODULE_NAME sqldrivers QMAKE_LIB ibase)
if(NOT WIN32 AND QT_FEATURE_system_zlib)
qt_add_qmake_lib_dependency(sqlite3 zlib)
endif()
Expand All @@ -33,7 +34,7 @@ qt_feature("sql-db2" PRIVATE
)
qt_feature("sql-ibase" PRIVATE
LABEL "InterBase"
CONDITION libs.ibase OR FIXME
CONDITION Interbase_FOUND
)
qt_feature("sql-mysql" PRIVATE
LABEL "MySql"
Expand Down
14 changes: 14 additions & 0 deletions src/plugins/sqldrivers/ibase/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
qt_internal_add_plugin(QIBaseDriverPlugin
OUTPUT_NAME qsqlibase
TYPE sqldrivers
SOURCES
main.cpp
qsql_ibase.cpp qsql_ibase_p.h
DEFINES
QT_NO_CAST_FROM_ASCII
QT_NO_CAST_TO_ASCII
PUBLIC_LIBRARIES
Interbase::Interbase
Qt::Core
Qt::CorePrivate
Qt::SqlPrivate)
36 changes: 19 additions & 17 deletions src/plugins/sqldrivers/ibase/qsql_ibase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ static void delDA(XSQLDA *&sqlda)
sqlda = 0;
}

static int qIBaseTypeName(int iType, bool hasScale)
static QMetaType::Type qIBaseTypeName(int iType, bool hasScale)
{
switch (iType) {
case blr_varying:
Expand Down Expand Up @@ -192,7 +192,7 @@ static int qIBaseTypeName(int iType, bool hasScale)
return QMetaType::UnknownType;
}

static int qIBaseTypeName2(int iType, bool hasScale)
static QMetaType::Type qIBaseTypeName2(int iType, bool hasScale)
{
switch(iType & ~1) {
case SQL_VARYING:
Expand Down Expand Up @@ -674,7 +674,7 @@ static char* qFillBufferWithString(char *buffer, const QString& string,
}

static char* createArrayBuffer(char *buffer, const QList<QVariant> &list,
int type, short curDim, ISC_ARRAY_DESC *arrayDesc,
QMetaType::Type type, short curDim, ISC_ARRAY_DESC *arrayDesc,
QString& error)
{
int i;
Expand Down Expand Up @@ -971,8 +971,9 @@ bool QIBaseResult::exec()
QList<QVariant>& values = boundValues();
int i;
if (values.count() > d->inda->sqld) {
qWarning("QIBaseResult::exec: Parameter mismatch, expected %d, got %d parameters",
d->inda->sqld, values.count());
qWarning() << QLatin1String("QIBaseResult::exec: Parameter mismatch, expected") <<
d->inda->sqld << QLatin1String(", got") << values.count() <<
QLatin1String("parameters");
return false;
}
int para = 0;
Expand Down Expand Up @@ -1137,17 +1138,18 @@ bool QIBaseResult::gotoNext(QSqlCachedResult::ValueCache& row, int rowIdx)
if ((d->sqlda->sqlvar[i].sqltype & 1) && *d->sqlda->sqlvar[i].sqlind) {
// null value
QVariant v;
v.convert(qIBaseTypeName2(d->sqlda->sqlvar[i].sqltype, d->sqlda->sqlvar[i].sqlscale < 0));
v.convert(QMetaType(qIBaseTypeName2(d->sqlda->sqlvar[i].sqltype,
d->sqlda->sqlvar[i].sqlscale < 0)));
if (v.userType() == QMetaType::Double) {
switch(numericalPrecisionPolicy()) {
case QSql::LowPrecisionInt32:
v.convert(QMetaType::Int);
v.convert(QMetaType(QMetaType::Int));
break;
case QSql::LowPrecisionInt64:
v.convert(QMetaType::LongLong);
v.convert(QMetaType(QMetaType::LongLong));
break;
case QSql::HighPrecision:
v.convert(QMetaType::QString);
v.convert(QMetaType(QMetaType::QString));
break;
case QSql::LowPrecisionDouble:
// no conversion
Expand Down Expand Up @@ -1220,19 +1222,19 @@ bool QIBaseResult::gotoNext(QSqlCachedResult::ValueCache& row, int rowIdx)
QVariant v = row[idx];
switch(numericalPrecisionPolicy()) {
case QSql::LowPrecisionInt32:
if (v.convert(QMetaType::Int))
if (v.convert(QMetaType(QMetaType::Int)))
row[idx]=v;
break;
case QSql::LowPrecisionInt64:
if (v.convert(QMetaType::LongLong))
if (v.convert(QMetaType(QMetaType::LongLong)))
row[idx]=v;
break;
case QSql::LowPrecisionDouble:
if (v.convert(QMetaType::Double))
if (v.convert(QMetaType(QMetaType::Double)))
row[idx]=v;
break;
case QSql::HighPrecision:
if (v.convert(QMetaType::QString))
if (v.convert(QMetaType(QMetaType::QString)))
row[idx]=v;
break;
}
Expand Down Expand Up @@ -1359,7 +1361,7 @@ QSqlRecord QIBaseResult::record() const
for (int i = 0; i < d->sqlda->sqld; ++i) {
v = d->sqlda->sqlvar[i];
QSqlField f(QString::fromLatin1(v.aliasname, v.aliasname_length).simplified(),
qIBaseTypeName2(v.sqltype, v.sqlscale < 0),
QMetaType(qIBaseTypeName2(v.sqltype, v.sqlscale < 0)),
QString::fromLatin1(v.relname, v.relname_length));
f.setLength(v.sqllen);
f.setPrecision(qAbs(v.sqlscale));
Expand Down Expand Up @@ -1647,7 +1649,7 @@ QSqlRecord QIBaseDriver::record(const QString& tablename) const
while (q.next()) {
int type = q.value(1).toInt();
bool hasScale = q.value(3).toInt() < 0;
QSqlField f(q.value(0).toString().simplified(), qIBaseTypeName(type, hasScale), tablename);
QSqlField f(q.value(0).toString().simplified(), QMetaType(qIBaseTypeName(type, hasScale)), tablename);
if (hasScale) {
f.setLength(q.value(4).toInt());
f.setPrecision(qAbs(q.value(3).toInt()));
Expand Down Expand Up @@ -1689,7 +1691,7 @@ QSqlIndex QIBaseDriver::primaryIndex(const QString &table) const

while (q.next()) {
QSqlField field(q.value(1).toString().simplified(),
qIBaseTypeName(q.value(2).toInt(), q.value(3).toInt() < 0),
QMetaType(qIBaseTypeName(q.value(2).toInt(), q.value(3).toInt() < 0)),
tablename);
index.append(field); //TODO: asc? desc?
index.setName(q.value(0).toString());
Expand All @@ -1700,7 +1702,7 @@ QSqlIndex QIBaseDriver::primaryIndex(const QString &table) const

QString QIBaseDriver::formatValue(const QSqlField &field, bool trimStrings) const
{
switch (field.type()) {
switch (field.metaType().id()) {
case QMetaType::QDateTime: {
QDateTime datetime = field.value().toDateTime();
if (datetime.isValid())
Expand Down

0 comments on commit feb2045

Please sign in to comment.