@@ -205,7 +205,7 @@ describe('Builder', function() {
205205
206206 expect ( result . query ) . to . be . equal ( 'select * from "users" where "name" = $1;' ) ;
207207 expect ( result . values ) . to . be . eql ( [ 'John' ] ) ;
208- } ) ;
208+ } ) ;
209209
210210 it ( 'should use prefix `@` for values with option `valuesPrefix` = @' , function ( ) {
211211 jsonSql . configure ( {
@@ -219,7 +219,7 @@ describe('Builder', function() {
219219
220220 expect ( result . query ) . to . be . equal ( 'select * from "users" where "name" = @p1;' ) ;
221221 expect ( result . values ) . to . be . eql ( { p1 : 'John' } ) ;
222- } ) ;
222+ } ) ;
223223
224224 it ( 'should return prefixed values with method `prefixValues`' , function ( ) {
225225 var result = jsonSql . build ( {
@@ -230,7 +230,7 @@ describe('Builder', function() {
230230 expect ( result . query ) . to . be . equal ( 'select * from "users" where "name" = @p1;' ) ;
231231 expect ( result . values ) . to . be . eql ( { p1 : 'John' } ) ;
232232 expect ( result . prefixValues ( ) ) . to . be . eql ( { '@p1' : 'John' } ) ;
233- } ) ;
233+ } ) ;
234234
235235 it ( 'should return array values with method `getValuesArray`' , function ( ) {
236236 var result = jsonSql . build ( {
@@ -260,6 +260,36 @@ describe('Builder', function() {
260260 expect ( result . values ) . to . be . eql ( [ 'John' ] ) ;
261261 expect ( result . prefixValues ( ) ) . to . be . eql ( { '$1' : 'John' } ) ;
262262 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' ] ) ;
263293 } ) ;
264294
265295 it ( 'should create query without values with option `separatedValues` = false' , function ( ) {
0 commit comments