| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145 | var Test = require('../../support/test-runner');describe('Query Generation ::', function() {  describe('UPDATE statements', function() {    it('should generate an update query', function(done) {      Test({        query: {          update: {            status: 'archived'          },          where: {            and: [              {                publishedDate: {                  '>': 2000                }              }            ]          },          using: 'books'        },        outcomes: [          {            dialect: 'postgresql',            sql: 'update "books" set "status" = $1 where "publishedDate" > $2',            bindings: ['archived', 2000]          },          {            dialect: 'mysql',            sql: 'update `books` set `status` = ? where `publishedDate` > ?',            bindings: ['archived', 2000]          },          {            dialect: 'sqlite3',            sql: 'update "books" set "status" = ? where "publishedDate" > ?',            bindings: ['archived', 2000]          },          {            dialect: 'oracle',            sql: 'update "books" set "status" = :1 where "publishedDate" > :2',            bindings: ['archived', 2000]          },          {            dialect: 'mariadb',            sql: 'update `books` set `status` = ? where `publishedDate` > ?',            bindings: ['archived', 2000]          }        ]      }, done);    });    it('should generate an update query where order doesn\'t matter', function(done) {      Test({        query: {          where: {            and: [              {                type: 'test'              }            ]          },          using: 'user',          update: {            age: 10          }        },        outcomes: [          {            dialect: 'postgresql',            sql: 'update "user" set "age" = $1 where "type" = $2',            bindings: [10, 'test']          },          {            dialect: 'mysql',            sql: 'update `user` set `age` = ? where `type` = ?',            bindings: [10, 'test']          },          {            dialect: 'sqlite3',            sql: 'update "user" set "age" = ? where "type" = ?',            bindings: [10, 'test']          },          {            dialect: 'oracle',            sql: 'update "user" set "age" = :1 where "type" = :2',            bindings: [10, 'test']          },          {            dialect: 'mariadb',            sql: 'update `user` set `age` = ? where `type` = ?',            bindings: [10, 'test']          }        ]      }, done);    });    it('should generate an insert query when using multiple values', function(done) {      Test({        query: {          update: {            status: 'archived',            active: false          },          where: {            and: [              {                publishedDate: {                  '>': 2000                }              }            ]          },          using: 'books'        },        outcomes: [          {            dialect: 'postgresql',            sql: 'update "books" set "active" = $1, "status" = $2 where "publishedDate" > $3',            bindings: [false, 'archived', 2000]          },          {            dialect: 'mysql',            sql: 'update `books` set `active` = ?, `status` = ? where `publishedDate` > ?',            bindings: [false, 'archived', 2000]          },          {            dialect: 'sqlite3',            sql: 'update "books" set "active" = ?, "status" = ? where "publishedDate" > ?',            bindings: [false, 'archived', 2000]          },          {            dialect: 'oracle',            sql: 'update "books" set "active" = :1, "status" = :2 where "publishedDate" > :3',            bindings: ['0', 'archived', 2000]          },          {            dialect: 'mariadb',            sql: 'update `books` set `active` = ?, `status` = ? where `publishedDate` > ?',            bindings: [false, 'archived', 2000]          }        ]      }, done);    });  });});
 |