null.test.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. var Test = require('../../support/test-runner');
  2. describe('Query Generation ::', function() {
  3. describe('NULL operator ::', function() {
  4. describe('IS NULL ::', function() {
  5. it('should generate a query when a NULL value is used', function(done) {
  6. Test({
  7. query: {
  8. select: ['*'],
  9. from: 'users',
  10. where: {
  11. and: [
  12. {
  13. updatedAt: null
  14. }
  15. ]
  16. }
  17. },
  18. outcomes: [
  19. {
  20. dialect: 'postgresql',
  21. sql: 'select * from "users" where "updatedAt" is null',
  22. bindings: []
  23. },
  24. {
  25. dialect: 'mysql',
  26. sql: 'select * from `users` where `updatedAt` is null',
  27. bindings: []
  28. },
  29. {
  30. dialect: 'sqlite3',
  31. sql: 'select * from "users" where "updatedAt" is null',
  32. bindings: []
  33. },
  34. {
  35. dialect: 'oracle',
  36. sql: 'select * from "users" where "updatedAt" is null',
  37. bindings: []
  38. },
  39. {
  40. dialect: 'mariadb',
  41. sql: 'select * from `users` where `updatedAt` is null',
  42. bindings: []
  43. }
  44. ]
  45. }, done);
  46. });
  47. });
  48. describe('IS NOT NULL ::', function() {
  49. it('should generate a query when a NOT NULL value is used', function(done) {
  50. Test({
  51. query: {
  52. select: ['*'],
  53. from: 'users',
  54. where: {
  55. and: [
  56. {
  57. not: {
  58. updatedAt: null
  59. }
  60. }
  61. ]
  62. }
  63. },
  64. outcome: 'select * from "users" where "updatedAt" is not null'
  65. }, done);
  66. });
  67. });
  68. });
  69. });