Ver código fonte

[Data.Sql] Added executed query to error message

@soyjavi 14 anos atrás
pai
commit
2f0b4f1e7e
1 arquivos alterados com 8 adições e 5 exclusões
  1. 8 5
      src/data/Lungo.Data.Sql.js

+ 8 - 5
src/data/Lungo.Data.Sql.js

@@ -119,10 +119,13 @@ LUNGO.Data.Sql = (function(lng, undefined) {
     var execute = function(sql, callback) {
         lng.Core.log(1, 'lng.Data.Sql >> ' + sql);
 
-        db.transaction(function(tx) {
-            tx.executeSql(sql, [], function(tx, rs) {
+        db.transaction( function(transaction) {
+            transaction.executeSql(sql, [], function(transaction, rs) {
                 _callbackResponse(callback, rs);
-            }, _throwError);
+            }, function(transaction, error) {
+                transaction.executedQuery = sql;
+                _throwError.apply(null, arguments);
+            });
         });
     };
 
@@ -195,10 +198,10 @@ LUNGO.Data.Sql = (function(lng, undefined) {
         }
 
         execute('INSERT INTO ' + table + ' (' + fields + ') VALUES (' + values + ')');
-    }
+    };
 
     var _throwError = function(transaction, error) {
-        lng.Core.log(3, 'lng.Data.Sql >> ' + error.code + ': ' + error.message);
+        lng.Core.log(3, 'lng.Data.Sql >> ' + error.code + ': ' + error.message + ' \n Executed query: ' + transaction.executedQuery);
     };
 
     return {