@@ -205,7 +205,7 @@ describe('Builder', function() {
205
205
206
206
expect ( result . query ) . to . be . equal ( 'select * from "users" where "name" = $1;' ) ;
207
207
expect ( result . values ) . to . be . eql ( [ 'John' ] ) ;
208
- } ) ;
208
+ } ) ;
209
209
210
210
it ( 'should use prefix `@` for values with option `valuesPrefix` = @' , function ( ) {
211
211
jsonSql . configure ( {
@@ -219,7 +219,7 @@ describe('Builder', function() {
219
219
220
220
expect ( result . query ) . to . be . equal ( 'select * from "users" where "name" = @p1;' ) ;
221
221
expect ( result . values ) . to . be . eql ( { p1 : 'John' } ) ;
222
- } ) ;
222
+ } ) ;
223
223
224
224
it ( 'should return prefixed values with method `prefixValues`' , function ( ) {
225
225
var result = jsonSql . build ( {
@@ -230,7 +230,7 @@ describe('Builder', function() {
230
230
expect ( result . query ) . to . be . equal ( 'select * from "users" where "name" = @p1;' ) ;
231
231
expect ( result . values ) . to . be . eql ( { p1 : 'John' } ) ;
232
232
expect ( result . prefixValues ( ) ) . to . be . eql ( { '@p1' : 'John' } ) ;
233
- } ) ;
233
+ } ) ;
234
234
235
235
it ( 'should return array values with method `getValuesArray`' , function ( ) {
236
236
var result = jsonSql . build ( {
@@ -260,6 +260,36 @@ describe('Builder', function() {
260
260
expect ( result . values ) . to . be . eql ( [ 'John' ] ) ;
261
261
expect ( result . prefixValues ( ) ) . to . be . eql ( { '$1' : 'John' } ) ;
262
262
expect ( result . getValuesObject ( ) ) . to . be . eql ( { 1 : 'John' } ) ;
263
+ } ) ;
264
+
265
+ it ( 'should throw if `indexedValues = false` and `namedValues = true`' , function ( ) {
266
+ jsonSql . configure ( {
267
+ namedValues : true ,
268
+ indexedValues : false
269
+ } ) ;
270
+
271
+ expect ( function ( ) {
272
+ jsonSql . build ( {
273
+ table : 'users' ,
274
+ condition : { name : 'John' }
275
+ } ) ;
276
+ } ) . to . throw ( 'Use of options "indexedValues: false" is ' +
277
+ 'not allowed together with "namedValues: true"' ) ;
278
+ } ) ;
279
+
280
+ it ( 'should not use index for values with option `indexedValues` = false' , function ( ) {
281
+ jsonSql . configure ( {
282
+ namedValues : false ,
283
+ indexedValues : false
284
+ } ) ;
285
+
286
+ var result = jsonSql . build ( {
287
+ table : 'users' ,
288
+ condition : { name : 'John' }
289
+ } ) ;
290
+
291
+ expect ( result . query ) . to . be . equal ( 'select * from "users" where "name" = $;' ) ;
292
+ expect ( result . values ) . to . be . eql ( [ 'John' ] ) ;
263
293
} ) ;
264
294
265
295
it ( 'should create query without values with option `separatedValues` = false' , function ( ) {
0 commit comments