@@ -5,26 +5,7 @@ import { localDate } from './__utils__/localDate.ts';
55
66const format = ( sql : string , values ?: SqlValue ) => _format ( sql , values , true ) ;
77
8- describe ( 'SELECT without values' , ( ) => {
9- it ( 'should return the query unchanged' , ( ) => {
10- const query = format ( 'SELECT * FROM users' , [ ] ) ;
11-
12- assert . strictEqual ( query , 'SELECT * FROM users' ) ;
13- } ) ;
14- } ) ;
15-
168describe ( 'SELECT with object parameter' , ( ) => {
17- it ( 'should generate a safe query for a legitimate string' , ( ) => {
18- const query = format ( 'SELECT * FROM users WHERE email = ?' , [
19- 'admin@example.com' ,
20- ] ) ;
21-
22- assert . strictEqual (
23- query ,
24- "SELECT * FROM users WHERE email = 'admin@example.com'"
25- ) ;
26- } ) ;
27-
289 it ( 'should not generate a SQL fragment for object { email: 1 }' , ( ) => {
2910 const query = format ( 'SELECT * FROM users WHERE email = ?' , [ { email : 1 } ] ) ;
3011
@@ -36,18 +17,6 @@ describe('SELECT with object parameter', () => {
3617} ) ;
3718
3819describe ( 'SELECT with multiple parameters' , ( ) => {
39- it ( 'should generate a safe query for a wrong password' , ( ) => {
40- const query = format (
41- 'SELECT * FROM users WHERE email = ? AND password = ?' ,
42- [ 'admin@example.com' , 'wrong_password' ]
43- ) ;
44-
45- assert . strictEqual (
46- query ,
47- "SELECT * FROM users WHERE email = 'admin@example.com' AND password = 'wrong_password'"
48- ) ;
49- } ) ;
50-
5120 it ( 'should not alter the query structure for object { email: 1 }' , ( ) => {
5221 const query = format (
5322 'SELECT * FROM users WHERE email = ? AND password = ?' ,
@@ -62,12 +31,6 @@ describe('SELECT with multiple parameters', () => {
6231} ) ;
6332
6433describe ( 'DELETE with object parameter' , ( ) => {
65- it ( 'should generate a safe query for a legitimate id' , ( ) => {
66- const query = format ( 'DELETE FROM users WHERE id = ?' , [ 1 ] ) ;
67-
68- assert . strictEqual ( query , 'DELETE FROM users WHERE id = 1' ) ;
69- } ) ;
70-
7134 it ( 'should not generate a SQL fragment for object { id: true }' , ( ) => {
7235 const query = format ( 'DELETE FROM users WHERE id = ?' , [ { id : true } ] ) ;
7336
@@ -203,42 +166,6 @@ describe('Object placeholder after SET but outside SET clause', () => {
203166 } ) ;
204167} ) ;
205168
206- describe ( 'Uint8Array parameter' , ( ) => {
207- it ( 'should format Uint8Array as hex string' , ( ) => {
208- const data = new Uint8Array ( [ 0x48 , 0x65 , 0x6c , 0x6c , 0x6f ] ) ; // "Hello" in hex
209- const query = format ( 'SELECT * FROM files WHERE data = ?' , [ data ] ) ;
210-
211- assert . strictEqual ( query , "SELECT * FROM files WHERE data = X'48656c6c6f'" ) ;
212- } ) ;
213-
214- it ( 'should format Uint8Array in INSERT statements' , ( ) => {
215- const data = new Uint8Array ( [ 0xde , 0xad , 0xbe , 0xef ] ) ;
216- const query = format ( 'INSERT INTO files (name, data) VALUES (?, ?)' , [
217- 'test' ,
218- data ,
219- ] ) ;
220-
221- assert . strictEqual (
222- query ,
223- "INSERT INTO files (name, data) VALUES ('test', X'deadbeef')"
224- ) ;
225- } ) ;
226-
227- it ( 'should format empty Uint8Array' , ( ) => {
228- const data = new Uint8Array ( [ ] ) ;
229- const query = format ( 'SELECT * FROM files WHERE data = ?' , [ data ] ) ;
230-
231- assert . strictEqual ( query , "SELECT * FROM files WHERE data = X''" ) ;
232- } ) ;
233-
234- it ( 'should not expand Uint8Array in SET clause' , ( ) => {
235- const data = new Uint8Array ( [ 0x01 , 0x02 ] ) ;
236- const query = format ( 'UPDATE files SET ?' , [ data ] ) ;
237-
238- assert . strictEqual ( query , "UPDATE files SET X'0102'" ) ;
239- } ) ;
240- } ) ;
241-
242169describe ( 'SET as a column name' , ( ) => {
243170 it ( 'should stringify object when SET is a column name in WHERE' , ( ) => {
244171 const query = format ( 'SELECT * FROM t WHERE SET = ? AND id = ?' , [
0 commit comments