Permalink
Browse files

Add failing tests for single quotes inside string.

  • Loading branch information...
1 parent f6e8e39 commit 0ac5c25137d8c697437ac360e091828ae77a3a0d @brainshave brainshave committed Feb 13, 2014
Showing with 68 additions and 1 deletion.
  1. +1 −1 test/driver/base_test.js
  2. +21 −0 test/driver/mysql_test.js
  3. +21 −0 test/driver/pg_test.js
  4. +25 −0 test/driver/sqlite3_test.js
@@ -62,7 +62,7 @@ vows.describe('base').addBatch({
},
'escapes single quotes': function(base) {
- assert.equal("Bill's Mother's House", base.escape("Bill's Mother's House"));
+ assert.equal("Bill''s Mother''s House", base.escape("Bill's Mother's House"));
}
}
}).export(module);
@@ -412,6 +412,27 @@ driver.connect({ driver: 'mysql', database: 'db_migrate_test', user:'root' }, fu
}
}
}).addBatch({
+ 'insertWithSingleQuotes': {
+ topic: function() {
+ db.createTable('event', {
+ id: { type: dataType.INTEGER, primaryKey: true, autoIncrement: true },
+ title: { type: dataType.STRING }
+ }, function() {
+ db.insert('event', ['id','title'], [2,"Bill's Mother's House"], this.callback.bind(this, null));
+ }.bind(this));
+ },
+
+ teardown: function() {
+ db.dropTable('event', this.callback);
+ },
+
+ 'with additional row' : function() {
+ db.runSql("SELECT * from event", function(err, data) {
+ assert.equal(data.length, 1);
+ });
+ }
+ }
+ }).addBatch({
'removeIndex': {
topic: function() {
db.createTable('event', {
@@ -354,6 +354,27 @@ driver.connect({ driver: 'pg', database: 'db_migrate_test' }, function(err, db)
}
}
}).addBatch({
+ 'insertWithSingleQuotes': {
+ topic: function() {
+ db.createTable('event', {
+ id: { type: dataType.INTEGER, primaryKey: true, autoIncrement: true },
+ title: { type: dataType.STRING }
+ }, function(err) {
+ db.insert('event', ['id','title'], [2,"Bill's Mother's House"], this.callback.bind(this, null));
+ }.bind(this));
+ },
+
+ 'with additional row' : function() {
+ db.runSql("SELECT * from event", function(err, data) {
+ assert.equal(data.rowCount, 1);
+ });
+ },
+
+ teardown: function() {
+ db.dropTable('event', this.callback);
+ }
+ }
+ }).addBatch({
'removeIndex': {
topic: function() {
db.createTable('event', {
@@ -283,6 +283,31 @@ vows.describe('sqlite3').addBatch({
}
}
}).addBatch({
+ 'insertWithSingleQuotes': {
+ topic: function () {
+ driver.connect({ driver: 'sqlite3', filename: 'test.db' }, function (err, db) {
+ db.createTable('event', {
+ id: { type: dataType.INTEGER, primaryKey: true, autoIncrement: true },
+ title: { type: dataType.STRING }
+ }, function () {
+ db.insert('event', ['id', 'title'], [2, "Bill's Mother's House"], this.callback.bind(this, null, db));
+ }.bind(this));
+ }.bind(this));
+ },
+
+ teardown: function (db) {
+ db.close(function (err) {
+ fs.unlink('test.db', this.callback);
+ });
+ },
+
+ 'with additional row': function (db) {
+ db.all("SELECT * from event;", function (err, data) {
+ assert.equal(data.length, 1);
+ });
+ }
+ }
+ }).addBatch({
'removeIndex': {
topic: function () {
driver.connect({ driver: 'sqlite3', filename: 'test.db' }, function (err, db) {

0 comments on commit 0ac5c25

Please sign in to comment.