HEX
Server: nginx/1.24.0
System: Linux nowruzgan 6.8.0-57-generic #59-Ubuntu SMP PREEMPT_DYNAMIC Sat Mar 15 17:40:59 UTC 2025 x86_64
User: babak (1000)
PHP: 8.3.6
Disabled: NONE
Upload Files
File: /var/dev/nowruzgan/rest/node_modules/waterline-sql-builder/test/benchmarks/generate-sql.test.js
var runBenchmarks = require('../support/benchmark-runner');
var sqlBuilder = require('../../index')({
  dialect: 'postgres'
});

//  ╔╗ ╔═╗╔╗╔╔═╗╦ ╦╔╦╗╔═╗╦═╗╦╔═╔═╗
//  ╠╩╗║╣ ║║║║  ╠═╣║║║╠═╣╠╦╝╠╩╗╚═╗
//  ╚═╝╚═╝╝╚╝╚═╝╩ ╩╩ ╩╩ ╩╩╚═╩ ╩╚═╝
describe('Benchmark :: Generate SQL', function() {
  // Set "timeout" and "slow" thresholds incredibly high
  // to avoid running into issues.
  this.slow(240000);
  this.timeout(240000);

  it('should be performant enough', function() {
    runBenchmarks('Sequelizer.execSync()', [
      function generateSelect() {
        sqlBuilder.generate({
          select: '*',
          from: 'books'
        });
      },

      function generateInsert() {
        sqlBuilder.generate({
          insert: {
            title: 'Slaughterhouse Five'
          },
          into: 'books'
        });
      },

      function generateUpdate() {
        sqlBuilder.generate({
          update: {
            status: 'archived'
          },
          where: {
            publishedDate: { '>': 2000 }
          },
          using: 'books'
        });
      },

      function generateDestroy() {
        sqlBuilder.generate({
          del: true,
          from: 'accounts',
          where: {
            activated: false
          }
        });
      },
    ]);
  });
});