-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathutil.js
25 lines (22 loc) · 885 Bytes
/
util.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import {escapeIdentifier, escapeLiteral} from '../lib/sql.js';
import t from 'tap';
t.test('Util', async t => {
t.test('escapeIdentifier', t => {
t.equal(escapeIdentifier(''), '""');
t.equal(escapeIdentifier('0'), '"0"');
t.equal(escapeIdentifier("Ain't misbehaving "), `"Ain't misbehaving "`);
t.equal(escapeIdentifier('NULL'), '"NULL"');
t.equal(escapeIdentifier('some"identifier'), '"some""identifier"');
t.end();
});
t.test('escapeLiteral', t => {
t.equal(escapeLiteral(''), "''");
t.equal(escapeLiteral('0'), "'0'");
t.equal(escapeLiteral("Ain't misbehaving "), "'Ain''t misbehaving '");
t.equal(escapeLiteral('NULL'), "'NULL'");
t.equal(escapeLiteral('some"identifier'), `'some"identifier'`);
t.equal(escapeLiteral(`backslash \\all' \the things`), ` E'backslash \\\\all'' \the things'`);
t.end();
});
t.end();
});