[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdepim/akonadi/server/src/storage
From:       Volker Krause <volker.krause () rwth-aachen ! de>
Date:       2006-09-30 14:20:45
Message-ID: 1159626045.568424.8356.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 590594 by vkrause:

- exec -> prepare/bind
- fix dbus call
- mysql fixes


 M  +24 -40    datastore.cpp  
 M  +4 -0      dbinitializer.cpp  


--- trunk/KDE/kdepim/akonadi/server/src/storage/datastore.cpp #590593:590594
@@ -312,11 +312,10 @@
     return Flag();
 
   QSqlQuery query( m_database );
-//  query.prepare( "SELECT id, name FROM Flags WHERE id = :id" );
-//  query.bindValue( ":id", id );
-  const QString statement = QString::fromLatin1( "SELECT id, name FROM Flags WHERE \
id = %1" ).arg( id ); +  query.prepare( QLatin1String("SELECT id, name FROM Flags \
WHERE id = :id") ); +  query.bindValue( QLatin1String(":id"), id );
 
-  if ( !query.exec( statement ) ) {
+  if ( !query.exec() ) {
     debugLastQueryError( query, "Error during selection of single Flag." );
     return Flag();
   }
@@ -338,11 +337,10 @@
     return Flag();
 
   QSqlQuery query( m_database );
-//  query.prepare( "SELECT id, name FROM Flags WHERE name = :id" );
-//  query.bindValue( ":id", id );
-  const QString statement = QString::fromLatin1( "SELECT id, name FROM Flags WHERE \
name = \"%1\"" ).arg( name ); +  query.prepare( QLatin1String("SELECT id, name FROM \
Flags WHERE name = :name") ); +  query.bindValue( QLatin1String(":name"), name );
 
-  if ( !query.exec( statement ) ) {
+  if ( !query.exec() ) {
     debugLastQueryError( query, "Error during selection of single Flag." );
     return Flag();
   }
@@ -1153,31 +1151,21 @@
 
   QSqlQuery query( m_database );
 
-  QSqlField field( QLatin1String("data"), QVariant::String );
-  field.setValue( data );
-  QString escaped = m_database.driver()->formatValue( field );
-  QString statement;
   if ( dateTime.isValid() ) {
-      statement = QString::fromLatin1( "INSERT INTO PimItems (remote_id, data, \
                location_id, mimetype_id, "
-                           "datetime ) "
-                           "VALUES ('%1', %2, %3, %4, '%5')")
-                         .arg( QString::fromUtf8( remote_id ) )
-                         .arg( escaped )
-                         .arg( location.id() )
-                         .arg( mimetype.id() )
-                         .arg( dateTimeFromQDateTime( dateTime ) );
-  }
-  else {
+      query.prepare( QLatin1String( "INSERT INTO PimItems (remote_id, data, \
location_id, mimetype_id, datetime ) " +                                    "VALUES \
(:remote_id, :data, :location_id, :mimetype_id, :datetime)") ); +      \
query.bindValue( QLatin1String(":datetime"), dateTimeFromQDateTime( dateTime ) ); +  \
} else {  // the database will use the current date/time for datetime
-      statement = QString::fromLatin1( "INSERT INTO PimItems (remote_id, data, \
                location_id, mimetype_id) "
-                           "VALUES ('%1', %2, %3, %4)")
-                         .arg( QString::fromUtf8(remote_id) )
-                         .arg( escaped )
-                         .arg( location.id() )
-                         .arg( mimetype.id() );
+      query.prepare( QLatin1String( "INSERT INTO PimItems (remote_id, data, \
location_id, mimetype_id) " +                                    "VALUES (:remote_id, \
:data, :location_i, :mimetype_id)") );  }
+  query.bindValue( QLatin1String(":remote_id"), QString::fromUtf8(remote_id) );
+  query.bindValue( QLatin1String(":data"), data );
+  query.bindValue( QLatin1String(":location_id"), location.id() );
+  query.bindValue( QLatin1String(":mimetype_id"), mimetype.id() );
 
-  if ( !query.exec( statement ) ) {
+  if ( !query.exec() ) {
     debugLastQueryError( query, "Error during insertion of single PimItem." );
     return false;
   }
@@ -1197,16 +1185,11 @@
     return false;
 
   QSqlQuery query( m_database );
+  query.prepare( QLatin1String("UPDATE PimItems SET data = :data WHERE id = :id") );
+  query.bindValue( QLatin1String(":data"), data );
+  query.bindValue( QLatin1String(":id"), pimItem.id() );
 
-  QSqlField field( QLatin1String("data"), QVariant::String );
-  field.setValue( data );
-  QString escaped = m_database.driver()->formatValue( field );
-  QString statement;
-  statement = QString::fromLatin1( "UPDATE PimItems SET data = %1 WHERE id = %2" )
-      .arg( escaped )
-      .arg( pimItem.id() );
-
-  if ( !query.exec( statement ) ) {
+  if ( !query.exec() ) {
     debugLastQueryError( query, "Error during insertion of single PimItem." );
     return false;
   }
@@ -1365,12 +1348,13 @@
 
     DBusThread *dbusThread = static_cast<DBusThread*>( QThread::currentThread() );
 
-    const QList<QVariant> result = dbusThread->callDBus( QLatin1String( \
"org.kde.Akonadi.Resource" ), +    const QList<QVariant> result = \
                dbusThread->callDBus( QLatin1String( "org.kde.Akonadi.Resource." ) + \
                r.resource(),
                                                          QLatin1String( "/" ),
-                                                         QLatin1String( \
"org.kde.Akonadi.Resource." ) + r.resource(), +                                       \
                QLatin1String( "org.kde.Akonadi.Resource" ),
                                                          QLatin1String( \
"requestItemDelivery" ), arguments );  
     // do something with result...
+    qDebug() << "got dbus response: " << result;
   }
   qDebug() << "returned from requestItemDelivery()";
 
--- trunk/KDE/kdepim/akonadi/server/src/storage/dbinitializer.cpp #590593:590594
@@ -117,7 +117,11 @@
       QString statement = QString::fromLatin1( "INSERT INTO %1 (%2) VALUES (%3)" )
           .arg( tableName )
           .arg( columnElement.attribute( QLatin1String("columns") ) )
+#if defined AKONADI_USE_MYSQL_EMBEDDED || defined AKONADI_USE_MYSQL
+          .arg( columnElement.attribute( QLatin1String("values") ).replace( \
QLatin1String("\\"), QLatin1String("\\\\") ) ); +#else
           .arg( columnElement.attribute( QLatin1String("values") ) );
+#endif
       dataList << statement;
     } else {
       mErrorMsg = QString::fromLatin1( "Unknown tag, expected <column> and got \
<%1>." ).arg( columnElement.tagName() );


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic