From 8d0da36dd21a104c8d4a98c0c7ec10c85e44bd45 Mon Sep 17 00:00:00 2001 From: Harish Karumuthil Date: Mon, 19 Jul 2021 00:59:06 +0530 Subject: [PATCH] Update test for #4 --- test.js | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/test.js b/test.js index 1c146b9..62c6c4a 100644 --- a/test.js +++ b/test.js @@ -1,11 +1,16 @@ /* global describe, it */ var assert = require('assert'); -var knex = require('knex')({client: 'pg' }); +var Knex = require('knex'); var knexJsonQuery = require('./'); require('simple-mocha'); +var testData = { + mysql:{}, + pg:{}, +}; -var conditions= [ +testData.pg.knex = Knex({client: 'pg' }); +testData.pg.conditions = [ /* -----------Tests for and conditions---------- */ { name: 'handle simple and conditions', @@ -157,6 +162,22 @@ var conditions= [ ]; +testData.mysql.knex = Knex({client: 'mysql' }); +testData.mysql.conditions = [ + /* -----------Tests for and conditions---------- */ + { + name: 'handle "and" condition with raw statement', + input: { f1: { $raw: '< `use_limit`' }, f2: 20 }, + output: 'select * where (`f1` < `use_limit` and `f2` = 20)' + }, +] + + +Object.keys( testData ).forEach(function(driver){ + var data = testData[driver]; + var conditions = data.conditions; + var knex = data.knex; + describe('SQL query generation from json query', function(){ conditions.forEach(function(v){ it( 'should ' + v.name , function(){ @@ -166,3 +187,5 @@ describe('SQL query generation from json query', function(){ }); }); +}) +