it('binds named parameters with the passed object and ignore numeric $1',function(){
vartypeCast=(dialect==='postgres')?'::int':'';
varlogSql;
returnthis.sequelize.query('select $one'+typeCast+' as foo, $two'+typeCast+' as bar, \'$1\' as baz',{raw:true,bind:{one:1,two:2},logging:function(s){logSql=s;}}).then(function(result){
it('binds named parameters with the passed array and ignore $alpha',function(){
vartypeCast=(dialect==='postgres')?'::int':'';
varlogSql;
returnthis.sequelize.query('select $1'+typeCast+' as foo, $2'+typeCast+' as bar, \'$foo\' as baz',{raw:true,bind:[1,2],logging:function(s){logSql=s;}}).then(function(result){
it('binds named parameters array handles escaped $$',function(){
it('binds named parameters array handles escaped $$',function(){
vartypeCast=(dialect==='postgres')?'::int':'';
vartypeCast=(dialect==='postgres')?'::int':'';
varlogSql;
varlogSql;
returnthis.sequelize.query('select $1'+typeCast+' as foo, \'$$\' as bar',{raw:true,bind:[1],logging:function(s){logSql=s;}}).then(function(result){
returnthis.sequelize.query('select $1'+typeCast+' as foo, \'$$ / $$1\' as bar',{raw:true,bind:[1],logging:function(s){logSql=s;}}).then(function(result){
it('binds named parameters object handles escaped $$',function(){
it('binds named parameters object handles escaped $$',function(){
vartypeCast=(dialect==='postgres')?'::int':'';
vartypeCast=(dialect==='postgres')?'::int':'';
varlogSql;
varlogSql;
returnthis.sequelize.query('select $one'+typeCast+' as foo, \'$$\' as bar',{raw:true,bind:{one:1},logging:function(s){logSql=s;}}).then(function(result){
returnthis.sequelize.query('select $one'+typeCast+' as foo, \'$$ / $$one\' as bar',{raw:true,bind:{one:1},logging:function(s){logSql=s;}}).then(function(result){
it('throw an exception when binds passed with object and numeric $1 is also present',function(){
varself=this;
vartypeCast=(dialect==='postgres')?'::int':'';
varlogSql;
expect(function(){
self.sequelize.query('select $one'+typeCast+' as foo, $two'+typeCast+' as bar, \'$1\' as baz',{raw:true,bind:{one:1,two:2},logging:function(s){logSql=s;}});
}).to.throw(Error,/Named bind parameter "\$\w+" has no value in the given object\./g);
});
it('throw an exception when binds passed as array and $alpha is also present',function(){
varself=this;
vartypeCast=(dialect==='postgres')?'::int':'';
varlogSql;
expect(function(){
self.sequelize.query('select $1'+typeCast+' as foo, $2'+typeCast+' as bar, \'$foo\' as baz',{raw:true,bind:[1,2],logging:function(s){logSql=s;}});
}).to.throw(Error,/Named bind parameter "\$\w+" has no value in the given object\./g);
});
it('throw an exception when bind key is $0 with the passed array',function(){
varself=this;
expect(function(){
self.sequelize.query('select $1 as foo, $0 as bar, $3 as baz',{raw:true,bind:[1,2]});
}).to.throw(Error,/Named bind parameter "\$\w+" has no value in the given object\./g);
});
it('throw an exception when bind key is $01 with the passed array',function(){
varself=this;
expect(function(){
self.sequelize.query('select $1 as foo, $01 as bar, $3 as baz',{raw:true,bind:[1,2]});
}).to.throw(Error,/Named bind parameter "\$\w+" has no value in the given object\./g);
});
it('throw an exception when bind key is missing in the passed array',function(){
it('throw an exception when bind key is missing in the passed array',function(){