A Twitch.tv viewer reward and games system.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

18 lines
650 B

12 years ago
  1. var Mysql = require('../../../');
  2. var common = require('../../common');
  3. var connection = common.createConnection();
  4. var assert = require('assert');
  5. connection.config.queryFormat = function (query, values, tz) {
  6. if (!values) return query;
  7. return query.replace(/\:(\w+)/g, function (txt, key) {
  8. if (values.hasOwnProperty(key)) {
  9. return this.escape(values[key]);
  10. }
  11. return txt;
  12. }.bind(this));
  13. };
  14. assert.equal(connection.format("SELECT :a1, :a2", { a1: 1, a2: 'two' }), "SELECT 1, 'two'");
  15. assert.equal(connection.format("SELECT :a1", []), "SELECT :a1");
  16. assert.equal(connection.format("SELECT :a1"), "SELECT :a1");