generate-sql.test.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. var runBenchmarks = require('../support/benchmark-runner');
  2. var sqlBuilder = require('../../index')({
  3. dialect: 'postgres'
  4. });
  5. // ╔╗ ╔═╗╔╗╔╔═╗╦ ╦╔╦╗╔═╗╦═╗╦╔═╔═╗
  6. // ╠╩╗║╣ ║║║║ ╠═╣║║║╠═╣╠╦╝╠╩╗╚═╗
  7. // ╚═╝╚═╝╝╚╝╚═╝╩ ╩╩ ╩╩ ╩╩╚═╩ ╩╚═╝
  8. describe('Benchmark :: Generate SQL', function() {
  9. // Set "timeout" and "slow" thresholds incredibly high
  10. // to avoid running into issues.
  11. this.slow(240000);
  12. this.timeout(240000);
  13. it('should be performant enough', function() {
  14. runBenchmarks('Sequelizer.execSync()', [
  15. function generateSelect() {
  16. sqlBuilder.generate({
  17. select: '*',
  18. from: 'books'
  19. });
  20. },
  21. function generateInsert() {
  22. sqlBuilder.generate({
  23. insert: {
  24. title: 'Slaughterhouse Five'
  25. },
  26. into: 'books'
  27. });
  28. },
  29. function generateUpdate() {
  30. sqlBuilder.generate({
  31. update: {
  32. status: 'archived'
  33. },
  34. where: {
  35. publishedDate: { '>': 2000 }
  36. },
  37. using: 'books'
  38. });
  39. },
  40. function generateDestroy() {
  41. sqlBuilder.generate({
  42. del: true,
  43. from: 'accounts',
  44. where: {
  45. activated: false
  46. }
  47. });
  48. },
  49. ]);
  50. });
  51. });