like.test.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. var Test = require('../../support/test-runner');
  2. describe('Query Generation ::', function() {
  3. describe('LIKE operator ::', function() {
  4. it('should generate a LIKE query', function(done) {
  5. Test({
  6. query: {
  7. select: ['*'],
  8. from: 'users',
  9. where: {
  10. or: [
  11. {
  12. name: {
  13. like: '%Test%'
  14. }
  15. },
  16. {
  17. id: {
  18. nin: [1, 2, 3]
  19. }
  20. }
  21. ]
  22. }
  23. },
  24. outcomes: [
  25. {
  26. dialect: 'postgresql',
  27. sql: 'select * from "users" where "name" like $1 or "id" not in ($2, $3, $4)',
  28. bindings: ['%Test%', '1', '2', '3']
  29. },
  30. {
  31. dialect: 'mysql',
  32. sql: 'select * from `users` where `name` like ? or `id` not in (?, ?, ?)',
  33. bindings: ['%Test%', '1', '2', '3']
  34. },
  35. {
  36. dialect: 'sqlite3',
  37. sql: 'select * from "users" where "name" like ? or "id" not in (?, ?, ?)',
  38. bindings: ['%Test%', '1', '2', '3']
  39. },
  40. {
  41. dialect: 'oracle',
  42. sql: 'select * from "users" where "name" like :1 or "id" not in (:2, :3, :4)',
  43. bindings: ['%Test%', '1', '2', '3']
  44. },
  45. {
  46. dialect: 'mariadb',
  47. sql: 'select * from `users` where `name` like ? or `id` not in (?, ?, ?)',
  48. bindings: ['%Test%', '1', '2', '3']
  49. }
  50. ]
  51. }, done);
  52. });
  53. });
  54. });