@@ -21,7 +21,6 @@ Harness.test({
2121 params : [ 'test' , 1 ]
2222} ) ;
2323
24-
2524Harness . test ( {
2625 query : post . insert ( post . content . value ( 'whoah' ) ) ,
2726 pg : {
@@ -325,3 +324,64 @@ Harness.test({
325324 } ,
326325 params : [ 'A%' ]
327326} ) ;
327+
328+ // Binary inserts
329+ Harness . test ( {
330+ query : post . insert ( post . content . value ( new Buffer ( 'test' ) ) , post . userId . value ( 2 ) ) ,
331+ pg : {
332+ text : 'INSERT INTO "post" ("content", "userId") VALUES ($1, $2)' ,
333+ string : 'INSERT INTO "post" ("content", "userId") VALUES (\'\\x74657374\', 2)'
334+ } ,
335+ sqlite : {
336+ text : 'INSERT INTO "post" ("content", "userId") VALUES ($1, $2)' ,
337+ string : 'INSERT INTO "post" ("content", "userId") VALUES (x\'74657374\', 2)'
338+ } ,
339+ mysql : {
340+ text : 'INSERT INTO `post` (`content`, `userId`) VALUES (?, ?)' ,
341+ string : 'INSERT INTO `post` (`content`, `userId`) VALUES (x\'74657374\', 2)'
342+ } ,
343+ params : [ new Buffer ( 'test' ) , 2 ]
344+ } ) ;
345+
346+ Harness . test ( {
347+ query : post . insert ( {
348+ content : new Buffer ( 'test' ) ,
349+ userId : 2
350+ } ) ,
351+ pg : {
352+ text : 'INSERT INTO "post" ("content", "userId") VALUES ($1, $2)' ,
353+ string : 'INSERT INTO "post" ("content", "userId") VALUES (\'\\x74657374\', 2)'
354+ } ,
355+ sqlite : {
356+ text : 'INSERT INTO "post" ("content", "userId") VALUES ($1, $2)' ,
357+ string : 'INSERT INTO "post" ("content", "userId") VALUES (x\'74657374\', 2)'
358+ } ,
359+ mysql : {
360+ text : 'INSERT INTO `post` (`content`, `userId`) VALUES (?, ?)' ,
361+ string : 'INSERT INTO `post` (`content`, `userId`) VALUES (x\'74657374\', 2)'
362+ } ,
363+ params : [ new Buffer ( 'test' ) , 2 ]
364+ } ) ;
365+
366+ Harness . test ( {
367+ query : post . insert ( [ {
368+ content : new Buffer ( 'whoah' )
369+ } , {
370+ content : new Buffer ( 'hey' )
371+ }
372+ ] ) ,
373+ pg : {
374+ text : 'INSERT INTO "post" ("content") VALUES ($1), ($2)' ,
375+ string : 'INSERT INTO "post" ("content") ' +
376+ 'VALUES (\'\\x77686f6168\'), (\'\\x686579\')'
377+ } ,
378+ sqlite : {
379+ text : 'INSERT INTO "post" ("content") VALUES ($1), ($2)' ,
380+ string : 'INSERT INTO "post" ("content") VALUES (x\'77686f6168\'), (x\'686579\')'
381+ } ,
382+ mysql : {
383+ text : 'INSERT INTO `post` (`content`) VALUES (?), (?)' ,
384+ string : 'INSERT INTO `post` (`content`) VALUES (x\'77686f6168\'), (x\'686579\')'
385+ } ,
386+ params : [ new Buffer ( 'whoah' ) , new Buffer ( 'hey' ) ]
387+ } ) ;
0 commit comments