[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: koffice/kexi/kexidb/drivers
From: Jaroslaw Staniek <js () iidea ! pl>
Date: 2005-02-27 18:24:05
Message-ID: 20050227182405.6A08B148A2 () office ! kde ! org
[Download RAW message or body]
CVS commit by staniek:
KexiDB
- mysql/sqlite drivers: fixed problem with xxxxConnection::value(int)
when we're using raw sql statements (so expanded field list is empty)
(thx to dipesh for the report)
M +33 -19 mySQL/mysqlcursor.cpp 1.17
M +3 -2 sqlite/sqlitecursor.cpp 1.39
--- koffice/kexi/kexidb/drivers/mySQL/mysqlcursor.cpp #1.16:1.17
@@ -1,19 +1,20 @@
/* This file is part of the KDE project
-Copyright (C) 2003 Joseph Wenninger<jowenn@kde.org>
+ Copyright (C) 2003 Joseph Wenninger<jowenn@kde.org>
+ Copyright (C) 2005 Jaroslaw Staniek <js@iidea.pl>
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU Library General Public
-License as published by the Free Software Foundation; either
-version 2 of the License, or (at your option) any later version.
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-Library General Public License for more details.
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
-You should have received a copy of the GNU Library General Public License
-along with this program; see the file COPYING. If not, write to
-the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA.
+ You should have received a copy of the GNU Library General Public License
+ along with this program; see the file COPYING. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
*/
@@ -109,8 +110,21 @@ void MySqlCursor::drv_getNextRecord() {
// This isn't going to work right now as it uses d->mysqlrow
QVariant MySqlCursor::value(uint pos) {
- if (!d->mysqlrow) return QVariant();
- if (pos>=m_fieldCount) return QVariant();
- if (d->mysqlrow[pos]==0) return QVariant();
- //js TODO: encode for type using m_fieldsExpanded like in SQLiteCursor::value()
+ if (!d->mysqlrow || pos>=m_fieldCount || d->mysqlrow[pos]==0)
+ return QVariant();
+
+ KexiDB::Field *f = (m_fieldsExpanded && pos<m_fieldsExpanded->count())
+ ? m_fieldsExpanded->at(pos)->field : 0;
+
+//! @todo js: handle DateTime, Date, Time, BLOB types!
+
+ //from most to least frequently used types:
+ if (!f || f->isTextType())
+ return QVariant( QString::fromUtf8((const char*)d->mysqlrow[pos]) );
+ else if (f->isIntegerType())
+ return QVariant( QCString((const char*)d->mysqlrow[pos]).toInt() );
+ else if (f->isFPNumericType())
+ return QVariant( QCString((const char*)d->mysqlrow[pos]).toDouble() );
+
+ //default
return QVariant(QString::fromUtf8((const char*)d->mysqlrow[pos]));
}
--- koffice/kexi/kexidb/drivers/sqlite/sqlitecursor.cpp #1.38:1.39
@@ -1,4 +1,4 @@
/* This file is part of the KDE project
- Copyright (C) 2003 Jaroslaw Staniek <js@iidea.pl>
+ Copyright (C) 2003-2005 Jaroslaw Staniek <js@iidea.pl>
This program is free software; you can redistribute it and/or
@@ -532,5 +532,6 @@ QVariant SQLiteCursor::value(uint i)
//TODO: allow disable range checking! - performance reasons
// const KexiDB::Field *f = m_query ? m_query->field(i) : 0;
- KexiDB::Field *f = m_fieldsExpanded ? m_fieldsExpanded->at(i)->field : 0;
+ KexiDB::Field *f = (m_fieldsExpanded && i<m_fieldsExpanded->count())
+ ? m_fieldsExpanded->at(i)->field : 0;
#ifdef SQLITE2
//from most to least frequently used types:
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic