Mercurial > dedupe
comparison SqliteDBLink.cpp @ 114:d4e337567960
Add some debug statements and fix a bug in SQL execution.
| author | Tom Fredrik Blenning Klaussen <bfg@bfgconsult.no> |
|---|---|
| date | Tue, 03 May 2016 02:26:39 +0200 |
| parents | 6cf5eb5b0be1 |
| children |
comparison
equal
deleted
inserted
replaced
| 113:27e628852401 | 114:d4e337567960 |
|---|---|
| 316 assert(checksums.size() == 0 || paths.size() == checksums.size()); | 316 assert(checksums.size() == 0 || paths.size() == checksums.size()); |
| 317 QSqlQuery* query; | 317 QSqlQuery* query; |
| 318 bool infoQuery; | 318 bool infoQuery; |
| 319 switch (operation) { | 319 switch (operation) { |
| 320 case Add: | 320 case Add: |
| 321 qDebug() << "Add"; | |
| 321 query = preparedTryAddQuery; | 322 query = preparedTryAddQuery; |
| 322 infoQuery = true; | 323 infoQuery = true; |
| 323 break; | 324 break; |
| 324 case Update: | 325 case Update: |
| 325 query = preparedUpdateQuery; | 326 query = preparedUpdateQuery; |
| 331 break; | 332 break; |
| 332 case None: | 333 case None: |
| 333 assert(paths.size() == 0); | 334 assert(paths.size() == 0); |
| 334 return; | 335 return; |
| 335 } | 336 } |
| 336 query->bindValue("path", paths); | 337 if (operation != Update) |
| 338 query->bindValue("path", paths); | |
| 337 if (infoQuery) { | 339 if (infoQuery) { |
| 338 query->bindValue("size", sizes); | 340 query->bindValue("size", sizes); |
| 339 query->bindValue("mtime", mtimes); | 341 query->bindValue("mtime", mtimes); |
| 340 query->bindValue("checksum", checksums); | 342 query->bindValue("checksum", checksums); |
| 341 } | 343 } |
| 344 //Because QT for some reason expect the parameters to be given in sequence | |
| 345 if (operation == Update) | |
| 346 query->bindValue("path", paths); | |
| 347 | |
| 342 | 348 |
| 343 if (!query->execBatch()) | 349 if (!query->execBatch()) |
| 344 throw SQLException(*query); | 350 throw SQLException(*query); |
| 345 | 351 |
| 346 paths.clear(); | 352 paths.clear(); |
| 374 const Operation* operation = | 380 const Operation* operation = |
| 375 (operations.empty()) ? NULL : operations.takeFirst(); | 381 (operations.empty()) ? NULL : operations.takeFirst(); |
| 376 | 382 |
| 377 while (operation) { | 383 while (operation) { |
| 378 if (operation->type() != last) { | 384 if (operation->type() != last) { |
| 385 qDebug() << "Execute Operation first" << typeString(last); | |
| 386 foreach(QVariant path, paths) { | |
| 387 qDebug() << path.toString(); | |
| 388 } | |
| 379 if (!preparedBeginQuery->exec()) | 389 if (!preparedBeginQuery->exec()) |
| 380 throw SQLException(*preparedBeginQuery); | 390 throw SQLException(*preparedBeginQuery); |
| 381 executeOperation(paths, sizes, mtimes, hashes, last); | 391 executeOperation(paths, sizes, mtimes, hashes, last); |
| 382 if (!preparedEndQuery->exec()) | 392 if (!preparedEndQuery->exec()) |
| 383 throw SQLException(*preparedEndQuery); | 393 throw SQLException(*preparedEndQuery); |
| 394 qDebug() << "Execute Operation Done"; | |
| 384 } | 395 } |
| 385 | 396 |
| 386 switch (operation->type()) { | 397 switch (operation->type()) { |
| 387 case Add: | 398 case Add: |
| 388 case Update: { | 399 case Update: { |
