Skip to content

Commit e504013

Browse files
Christopher J. BrodyChristopher J. Brody
Christopher J. Brody
authored and
Christopher J. Brody
committed
'012012012' string INSERT value bindings test
ref: storesafe#791
1 parent c5db72f commit e504013

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed

spec/www/spec/db-tx-value-bindings-test.js

+57
Original file line numberDiff line numberDiff line change
@@ -773,6 +773,63 @@ var mytests = function() {
773773
});
774774
}, MYTIMEOUT);
775775

776+
it(suiteName + "'012012012' string INSERT value bindings", function(done) {
777+
// Verified working as expected
778+
// ref: litehelpers/Cordova-sqlite-storage#791
779+
var db = openDatabase('012012012-string-INSERT-value-bindings-test.db');
780+
781+
var myValue = '012012012';
782+
var myValueAsWholeNumber = 12012012;
783+
784+
db.transaction(function(tx) {
785+
tx.executeSql('DROP TABLE IF EXISTS tt');
786+
tx.executeSql('CREATE TABLE IF NOT EXISTS tt (data1, data2 TEXT, data3 NUMERIC, data4 INTEGER, data5 REAL)', null, function(ignored1, ignored2) {
787+
tx.executeSql('INSERT INTO tt VALUES (?,?,?,?,?)',
788+
[myValue, myValue, myValue, myValue, myValue], function(ignored, rs1) {
789+
expect(rs1).toBeDefined();
790+
expect(rs1.rowsAffected).toBe(1);
791+
expect(rs1.insertId).toBe(1);
792+
793+
tx.executeSql('SELECT * FROM tt', [], function(ignored, rs2) {
794+
expect(rs2).toBeDefined();
795+
expect(rs2.rows).toBeDefined();
796+
expect(rs2.rows.length).toBe(1);
797+
798+
var resultRow2 = rs2.rows.item(0);
799+
expect(resultRow2.data1).toBe(myValue);
800+
expect(resultRow2.data2).toBe(myValue);
801+
expect(resultRow2.data3).toBe(myValueAsWholeNumber);
802+
expect(resultRow2.data4).toBe(myValueAsWholeNumber);
803+
expect(resultRow2.data5).toBe(myValueAsWholeNumber);
804+
805+
tx.executeSql('SELECT TYPEOF(data1) AS t1, TYPEOF(data2) AS t2, TYPEOF(data3) AS t3, TYPEOF(data4) AS t4, TYPEOF(data5) AS t5 FROM tt', [], function(ignored, rs3) {
806+
expect(rs3).toBeDefined();
807+
expect(rs3.rows).toBeDefined();
808+
expect(rs3.rows.length).toBe(1);
809+
810+
var resultRow3 = rs3.rows.item(0);
811+
expect(resultRow3.t1).toBe('text');
812+
expect(resultRow3.t2).toBe('text');
813+
expect(resultRow3.t3).toBe('integer');
814+
expect(resultRow3.t4).toBe('integer');
815+
expect(resultRow3.t5).toBe('real');
816+
817+
// Close (plugin only) & finish:
818+
(isWebSql) ? done() : db.close(done, done);
819+
});
820+
821+
});
822+
});
823+
});
824+
}, function(error) {
825+
// NOT EXPECTED:
826+
expect(false).toBe(true);
827+
expect(error.message).toBe('---');
828+
// Close (plugin only) & finish:
829+
(isWebSql) ? done() : db.close(done, done);
830+
});
831+
}, MYTIMEOUT);
832+
776833
it(suiteName + "executeSql parameter as array", function(done) {
777834
var db = openDatabase("array-parameter.db", "1.0", "Demo", DEFAULT_SIZE);
778835

0 commit comments

Comments
 (0)