Skip to content

Commit

Permalink
Bug fix for errors in change log creation
Browse files Browse the repository at this point in the history
QSqlQuery::prepare should be used once the query string has been created
so that the bind values are correclty bound to the query

Signed-off-by: Sateesh Kavuri <sateesh.kavuri@gmail.com>
  • Loading branch information
kavuri committed Aug 7, 2013
1 parent fda3ac3 commit e9d9263
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/ChangeLog.cpp
Expand Up @@ -280,6 +280,7 @@ bool ChangeLog::loadAnchors( QSqlDatabase& aDbHandle )
const QString queryString( "SELECT local_sync_anchor, remote_sync_anchor, last_sync_time FROM change_logs WHERE remote_device = :remote_device AND source_db_uri = :source_db_uri AND sync_direction = :sync_direction" );

QSqlQuery query( queryString, aDbHandle );
query.prepare( queryString );
query.bindValue( ":remote_device", iRemoteDevice );
query.bindValue( ":source_db_uri", iSourceDbURI );
query.bindValue( ":sync_direction", iSyncDirection );
Expand Down Expand Up @@ -322,6 +323,7 @@ bool ChangeLog::saveAnchors( QSqlDatabase& aDbHandle )
const QString queryString( "INSERT INTO change_logs(remote_device, source_db_uri, sync_direction, local_sync_anchor, remote_sync_anchor, last_sync_time) VALUES (:remote_device, :source_db_uri, :sync_direction, :local_sync_anchor, :remote_sync_anchor, :last_sync_time)" );

QSqlQuery query( queryString, aDbHandle );
query.prepare( queryString );
query.bindValue( ":remote_device", iRemoteDevice );
query.bindValue( ":source_db_uri", iSourceDbURI );
query.bindValue( ":sync_direction", iSyncDirection );
Expand Down Expand Up @@ -366,6 +368,7 @@ bool ChangeLog::removeAnchors( QSqlDatabase& aDbHandle )
const QString queryString( "DELETE FROM change_logs WHERE remote_device = :remote_device AND source_db_uri = :source_db_uri AND sync_direction = :sync_direction" );

QSqlQuery query( queryString, aDbHandle );
query.prepare( queryString );
query.bindValue( ":remote_device", iRemoteDevice );
query.bindValue( ":source_db_uri", iSourceDbURI );
query.bindValue( ":sync_direction", iSyncDirection );
Expand All @@ -390,6 +393,7 @@ bool ChangeLog::loadMaps( QSqlDatabase& aDbHandle )
const QString queryString("SELECT local_id, remote_id FROM id_maps WHERE remote_device = :remote_device AND source_db_uri = :source_db_uri AND sync_direction = :sync_direction" );

QSqlQuery query( queryString, aDbHandle );
query.prepare( queryString );
query.bindValue( ":remote_device", iRemoteDevice );
query.bindValue( ":source_db_uri", iSourceDbURI );
query.bindValue( ":sync_direction", iSyncDirection );
Expand Down Expand Up @@ -428,6 +432,7 @@ bool ChangeLog::saveMaps( QSqlDatabase& aDbHandle )
const QString queryString( "INSERT INTO id_maps(remote_device, source_db_uri, sync_direction, local_id, remote_id) values(:remote_device, :source_db_uri, :sync_direction, :local_id, :remote_id)" );

QSqlQuery query( queryString, aDbHandle );
query.prepare( queryString );

QVariantList device;
QVariantList sourceDbURI;
Expand Down Expand Up @@ -481,6 +486,7 @@ bool ChangeLog::removeMaps( QSqlDatabase& aDbHandle )
const QString queryString( "DELETE FROM id_maps WHERE remote_device = :remote_device AND source_db_uri = :source_db_uri AND sync_direction = :sync_direction" );

QSqlQuery query( queryString, aDbHandle );
query.prepare( queryString );
query.bindValue( ":remote_device", iRemoteDevice );
query.bindValue( ":source_db_uri", iSourceDbURI );
query.bindValue( ":sync_direction", iSyncDirection );
Expand Down

0 comments on commit e9d9263

Please sign in to comment.