From kde-commits Fri Aug 27 15:36:13 2010 From: Sebastian Trueg Date: Fri, 27 Aug 2010 15:36:13 +0000 To: kde-commits Subject: kdesupport/soprano Message-Id: <20100827153613.CFD72AC857 () svn ! kde ! org> X-MARC-Message: https://marc.info/?l=kde-commits&m=128292317828615 SVN commit 1168854 by trueg: Since Virtuoso does not support xsd:boolean Soprano has a fake boolean type which is already supported in the statement based methods and the QueryResultIterator. This commit adds very rudimentary support in SPARQL queries by replacing any occurrenceof "true|false"^^xsd:boolean by the fake type. This is far from being full support and it might even do some damage when a literal contains a matching string but so far I do not see a better solution (besides Virtuoso supporting boolean types of course). M +1 -1 CMakeLists.txt M +3 -0 ChangeLog M +8 -1 backends/virtuoso/virtuosomodel.cpp M +9 -0 backends/virtuoso/virtuosomodel_p.h --- trunk/kdesupport/soprano/CMakeLists.txt #1168853:1168854 @@ -7,7 +7,7 @@ ################## Soprano version ################################ set(CMAKE_SOPRANO_VERSION_MAJOR 2) set(CMAKE_SOPRANO_VERSION_MINOR 5) -set(CMAKE_SOPRANO_VERSION_RELEASE 60) +set(CMAKE_SOPRANO_VERSION_RELEASE 61) set(CMAKE_SOPRANO_VERSION_STRING "${CMAKE_SOPRANO_VERSION_MAJOR}.${CMAKE_SOPRANO_VERSION_MINOR}.${CMAKE_SOPRANO_VERSION_RELEASE}") --- trunk/kdesupport/soprano/ChangeLog #1168853:1168854 @@ -1,3 +1,6 @@ +2.6.0 + * Fixed handling of xsd:boolean in SPARQL queries in the Virtuoso backend + 2.5.0 * New public qHash method for Statement * New Node::fromN3 method and operator>> which allows to parse nodes from N3 encoding. --- trunk/kdesupport/soprano/backends/virtuoso/virtuosomodel.cpp #1168853:1168854 @@ -106,6 +106,13 @@ } +QString Soprano::VirtuosoModelPrivate::replaceFakeTypesInQuery( const QString& query ) +{ + QMutexLocker lock( &m_fakeBooleanRegExpMutex ); + return QString(query).replace( m_fakeBooleanRegExp, QString::fromLatin1("'\\2'^^<%1>").arg( Virtuoso::fakeBooleanTypeString() ) ); +} + + Soprano::VirtuosoModel::VirtuosoModel( ODBC::ConnectionPool* connectionPool, const Backend* b ) : StorageModel(b), d( new VirtuosoModelPrivate() ) @@ -404,7 +411,7 @@ { // qDebug() << Q_FUNC_INFO << query; - QString finalQuery( query ); + QString finalQuery = d->replaceFakeTypesInQuery( query ); if ( language != Soprano::Query::QueryLanguageSparql ) { setError( Error::Error( QString::fromLatin1( "Unsupported query language %1." ) --- trunk/kdesupport/soprano/backends/virtuoso/virtuosomodel_p.h #1168853:1168854 @@ -23,6 +23,7 @@ #define _SOPRANO_IODBC_MODEL_P_H_ #include +#include #include "virtuosoqueryresultiteratorbackend.h" @@ -37,6 +38,9 @@ public: VirtuosoModelPrivate() : connectionPool( 0 ), + m_fakeBooleanRegExp( QLatin1String("([\"'])(true|false)\\1\\^\\^(|\\w+\\:boolean)"), + Qt::CaseInsensitive, + QRegExp::RegExp2 ), m_openIteratorMutex( QMutex::Recursive ) { } @@ -59,10 +63,15 @@ m_openIteratorMutex.unlock(); } + QString replaceFakeTypesInQuery( const QString& query ); + ODBC::ConnectionPool* connectionPool; QList m_openIterators; private: + QRegExp m_fakeBooleanRegExp; + QMutex m_fakeBooleanRegExpMutex; + QMutex m_openIteratorMutex; }; }