leftOuterJoin.test.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. var Test = require('../../support/test-runner');
  2. describe('Query Generation ::', function() {
  3. describe('LEFT OUTER JOINS ::', function() {
  4. it('should generate a basic left outer join query', function(done) {
  5. Test({
  6. query: {
  7. select: ['users.id', 'contacts.phone'],
  8. from: 'users',
  9. leftOuterJoin: [
  10. {
  11. from: 'contacts',
  12. on: {
  13. users: 'id',
  14. contacts: 'user_id'
  15. }
  16. }
  17. ]
  18. },
  19. outcomes: [
  20. {
  21. dialect: 'postgresql',
  22. sql: 'select "users"."id", "contacts"."phone" from "users" left outer join "contacts" on "users"."id" = "contacts"."user_id"',
  23. bindings: []
  24. },
  25. {
  26. dialect: 'mysql',
  27. sql: 'select `users`.`id`, `contacts`.`phone` from `users` left outer join `contacts` on `users`.`id` = `contacts`.`user_id`',
  28. bindings: []
  29. },
  30. {
  31. dialect: 'sqlite3',
  32. sql: 'select "users"."id", "contacts"."phone" from "users" left outer join "contacts" on "users"."id" = "contacts"."user_id"',
  33. bindings: []
  34. },
  35. {
  36. dialect: 'oracle',
  37. sql: 'select "users"."id", "contacts"."phone" from "users" left outer join "contacts" on "users"."id" = "contacts"."user_id"',
  38. bindings: []
  39. },
  40. {
  41. dialect: 'mariadb',
  42. sql: 'select `users`.`id`, `contacts`.`phone` from `users` left outer join `contacts` on `users`.`id` = `contacts`.`user_id`',
  43. bindings: []
  44. }
  45. ]
  46. }, done);
  47. });
  48. });
  49. });