pqb 0.7.4 → 0.7.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pqb",
3
- "version": "0.7.4",
3
+ "version": "0.7.5",
4
4
  "description": "Postgres query builder",
5
5
  "homepage": "https://orchid-orm.netlify.app/guide/query-builder-setup.html",
6
6
  "repository": {
@@ -277,7 +277,7 @@ describe('operators', () => {
277
277
  User.where({ name: { contains: 'ko' } }).toSql(),
278
278
  `
279
279
  SELECT * FROM "user"
280
- WHERE "user"."name" LIKE '%' || $1 || '%'
280
+ WHERE "user"."name" ILIKE '%' || $1 || '%'
281
281
  `,
282
282
  ['ko'],
283
283
  );
@@ -288,7 +288,7 @@ describe('operators', () => {
288
288
  User.where({ name: { contains: User.select('name').take() } }).toSql(),
289
289
  `
290
290
  SELECT * FROM "user"
291
- WHERE "user"."name" LIKE '%' || (SELECT "user"."name" FROM "user" LIMIT $1) || '%'
291
+ WHERE "user"."name" ILIKE '%' || (SELECT "user"."name" FROM "user" LIMIT $1) || '%'
292
292
  `,
293
293
  [1],
294
294
  );
@@ -299,19 +299,19 @@ describe('operators', () => {
299
299
  User.where({ name: { contains: db.raw("'ko'") } }).toSql(),
300
300
  `
301
301
  SELECT * FROM "user"
302
- WHERE "user"."name" LIKE '%' || 'ko' || '%'
302
+ WHERE "user"."name" ILIKE '%' || 'ko' || '%'
303
303
  `,
304
304
  );
305
305
  });
306
306
  });
307
307
 
308
- describe('containsInsensitive', () => {
308
+ describe('containsSensitive', () => {
309
309
  it('should handle value', () => {
310
310
  expectSql(
311
- User.where({ name: { containsInsensitive: 'ko' } }).toSql(),
311
+ User.where({ name: { containsSensitive: 'ko' } }).toSql(),
312
312
  `
313
313
  SELECT * FROM "user"
314
- WHERE "user"."name" ILIKE '%' || $1 || '%'
314
+ WHERE "user"."name" LIKE '%' || $1 || '%'
315
315
  `,
316
316
  ['ko'],
317
317
  );
@@ -320,11 +320,11 @@ describe('operators', () => {
320
320
  it('should handle sub query', () => {
321
321
  expectSql(
322
322
  User.where({
323
- name: { containsInsensitive: User.select('name').take() },
323
+ name: { containsSensitive: User.select('name').take() },
324
324
  }).toSql(),
325
325
  `
326
326
  SELECT * FROM "user"
327
- WHERE "user"."name" ILIKE '%' || (SELECT "user"."name" FROM "user" LIMIT $1) || '%'
327
+ WHERE "user"."name" LIKE '%' || (SELECT "user"."name" FROM "user" LIMIT $1) || '%'
328
328
  `,
329
329
  [1],
330
330
  );
@@ -332,10 +332,10 @@ describe('operators', () => {
332
332
 
333
333
  it('should handle raw query', () => {
334
334
  expectSql(
335
- User.where({ name: { containsInsensitive: db.raw("'ko'") } }).toSql(),
335
+ User.where({ name: { containsSensitive: db.raw("'ko'") } }).toSql(),
336
336
  `
337
337
  SELECT * FROM "user"
338
- WHERE "user"."name" ILIKE '%' || 'ko' || '%'
338
+ WHERE "user"."name" LIKE '%' || 'ko' || '%'
339
339
  `,
340
340
  );
341
341
  });
@@ -347,7 +347,7 @@ describe('operators', () => {
347
347
  User.where({ name: { startsWith: 'ko' } }).toSql(),
348
348
  `
349
349
  SELECT * FROM "user"
350
- WHERE "user"."name" LIKE $1 || '%'
350
+ WHERE "user"."name" ILIKE $1 || '%'
351
351
  `,
352
352
  ['ko'],
353
353
  );
@@ -360,7 +360,7 @@ describe('operators', () => {
360
360
  }).toSql(),
361
361
  `
362
362
  SELECT * FROM "user"
363
- WHERE "user"."name" LIKE (SELECT "user"."name" FROM "user" LIMIT $1) || '%'
363
+ WHERE "user"."name" ILIKE (SELECT "user"."name" FROM "user" LIMIT $1) || '%'
364
364
  `,
365
365
  [1],
366
366
  );
@@ -371,19 +371,19 @@ describe('operators', () => {
371
371
  User.where({ name: { startsWith: db.raw("'ko'") } }).toSql(),
372
372
  `
373
373
  SELECT * FROM "user"
374
- WHERE "user"."name" LIKE 'ko' || '%'
374
+ WHERE "user"."name" ILIKE 'ko' || '%'
375
375
  `,
376
376
  );
377
377
  });
378
378
  });
379
379
 
380
- describe('startsWithInsensitive', () => {
380
+ describe('startsWithSensitive', () => {
381
381
  it('should handle value', () => {
382
382
  expectSql(
383
- User.where({ name: { startsWithInsensitive: 'ko' } }).toSql(),
383
+ User.where({ name: { startsWithSensitive: 'ko' } }).toSql(),
384
384
  `
385
385
  SELECT * FROM "user"
386
- WHERE "user"."name" ILIKE $1 || '%'
386
+ WHERE "user"."name" LIKE $1 || '%'
387
387
  `,
388
388
  ['ko'],
389
389
  );
@@ -392,11 +392,11 @@ describe('operators', () => {
392
392
  it('should handle sub query', () => {
393
393
  expectSql(
394
394
  User.where({
395
- name: { startsWithInsensitive: User.select('name').take() },
395
+ name: { startsWithSensitive: User.select('name').take() },
396
396
  }).toSql(),
397
397
  `
398
398
  SELECT * FROM "user"
399
- WHERE "user"."name" ILIKE (SELECT "user"."name" FROM "user" LIMIT $1) || '%'
399
+ WHERE "user"."name" LIKE (SELECT "user"."name" FROM "user" LIMIT $1) || '%'
400
400
  `,
401
401
  [1],
402
402
  );
@@ -404,10 +404,10 @@ describe('operators', () => {
404
404
 
405
405
  it('should handle raw query', () => {
406
406
  expectSql(
407
- User.where({ name: { startsWithInsensitive: db.raw("'ko'") } }).toSql(),
407
+ User.where({ name: { startsWithSensitive: db.raw("'ko'") } }).toSql(),
408
408
  `
409
409
  SELECT * FROM "user"
410
- WHERE "user"."name" ILIKE 'ko' || '%'
410
+ WHERE "user"."name" LIKE 'ko' || '%'
411
411
  `,
412
412
  );
413
413
  });
@@ -419,7 +419,7 @@ describe('operators', () => {
419
419
  User.where({ name: { endsWith: 'ko' } }).toSql(),
420
420
  `
421
421
  SELECT * FROM "user"
422
- WHERE "user"."name" LIKE '%' || $1
422
+ WHERE "user"."name" ILIKE '%' || $1
423
423
  `,
424
424
  ['ko'],
425
425
  );
@@ -432,7 +432,7 @@ describe('operators', () => {
432
432
  }).toSql(),
433
433
  `
434
434
  SELECT * FROM "user"
435
- WHERE "user"."name" LIKE '%' || (SELECT "user"."name" FROM "user" LIMIT $1)
435
+ WHERE "user"."name" ILIKE '%' || (SELECT "user"."name" FROM "user" LIMIT $1)
436
436
  `,
437
437
  [1],
438
438
  );
@@ -443,19 +443,19 @@ describe('operators', () => {
443
443
  User.where({ name: { endsWith: db.raw("'ko'") } }).toSql(),
444
444
  `
445
445
  SELECT * FROM "user"
446
- WHERE "user"."name" LIKE '%' || 'ko'
446
+ WHERE "user"."name" ILIKE '%' || 'ko'
447
447
  `,
448
448
  );
449
449
  });
450
450
  });
451
451
 
452
- describe('endsWithInsensitive', () => {
452
+ describe('endsWithSensitive', () => {
453
453
  it('should handle value', () => {
454
454
  expectSql(
455
- User.where({ name: { endsWithInsensitive: 'ko' } }).toSql(),
455
+ User.where({ name: { endsWithSensitive: 'ko' } }).toSql(),
456
456
  `
457
457
  SELECT * FROM "user"
458
- WHERE "user"."name" ILIKE '%' || $1
458
+ WHERE "user"."name" LIKE '%' || $1
459
459
  `,
460
460
  ['ko'],
461
461
  );
@@ -464,11 +464,11 @@ describe('operators', () => {
464
464
  it('should handle sub query', () => {
465
465
  expectSql(
466
466
  User.where({
467
- name: { endsWithInsensitive: User.select('name').take() },
467
+ name: { endsWithSensitive: User.select('name').take() },
468
468
  }).toSql(),
469
469
  `
470
470
  SELECT * FROM "user"
471
- WHERE "user"."name" ILIKE '%' || (SELECT "user"."name" FROM "user" LIMIT $1)
471
+ WHERE "user"."name" LIKE '%' || (SELECT "user"."name" FROM "user" LIMIT $1)
472
472
  `,
473
473
  [1],
474
474
  );
@@ -476,10 +476,10 @@ describe('operators', () => {
476
476
 
477
477
  it('should handle raw query', () => {
478
478
  expectSql(
479
- User.where({ name: { endsWithInsensitive: db.raw("'ko'") } }).toSql(),
479
+ User.where({ name: { endsWithSensitive: db.raw("'ko'") } }).toSql(),
480
480
  `
481
481
  SELECT * FROM "user"
482
- WHERE "user"."name" ILIKE '%' || 'ko'
482
+ WHERE "user"."name" LIKE '%' || 'ko'
483
483
  `,
484
484
  );
485
485
  });
@@ -77,31 +77,31 @@ const all = {
77
77
  contains: <T>() =>
78
78
  createOperator<T | Query | RawExpression>(
79
79
  (key, value, values) =>
80
- `${key} LIKE '%' || ${quoteValue(value, values)} || '%'`,
80
+ `${key} ILIKE '%' || ${quoteValue(value, values)} || '%'`,
81
81
  ),
82
- containsInsensitive: <T>() =>
82
+ containsSensitive: <T>() =>
83
83
  createOperator<T | Query | RawExpression>(
84
84
  (key, value, values) =>
85
- `${key} ILIKE '%' || ${quoteValue(value, values)} || '%'`,
85
+ `${key} LIKE '%' || ${quoteValue(value, values)} || '%'`,
86
86
  ),
87
87
  startsWith: <T>() =>
88
- createOperator<T | Query | RawExpression>(
89
- (key, value, values) => `${key} LIKE ${quoteValue(value, values)} || '%'`,
90
- ),
91
- startsWithInsensitive: <T>() =>
92
88
  createOperator<T | Query | RawExpression>(
93
89
  (key, value, values) =>
94
90
  `${key} ILIKE ${quoteValue(value, values)} || '%'`,
95
91
  ),
96
- endsWith: <T>() =>
92
+ startsWithSensitive: <T>() =>
97
93
  createOperator<T | Query | RawExpression>(
98
- (key, value, values) => `${key} LIKE '%' || ${quoteValue(value, values)}`,
94
+ (key, value, values) => `${key} LIKE ${quoteValue(value, values)} || '%'`,
99
95
  ),
100
- endsWithInsensitive: <T>() =>
96
+ endsWith: <T>() =>
101
97
  createOperator<T | Query | RawExpression>(
102
98
  (key, value, values) =>
103
99
  `${key} ILIKE '%' || ${quoteValue(value, values)}`,
104
100
  ),
101
+ endsWithSensitive: <T>() =>
102
+ createOperator<T | Query | RawExpression>(
103
+ (key, value, values) => `${key} LIKE '%' || ${quoteValue(value, values)}`,
104
+ ),
105
105
  between: <T>() =>
106
106
  createOperator<[T | Query | RawExpression, T | Query | RawExpression]>(
107
107
  (key, [from, to], values) =>
@@ -148,11 +148,11 @@ const numeric = <T>() => ({
148
148
  const text = <T>() => ({
149
149
  ...base<T>(),
150
150
  contains: all.contains<T>(),
151
- containsInsensitive: all.containsInsensitive<T>(),
151
+ containsSensitive: all.containsSensitive<T>(),
152
152
  startsWith: all.startsWith<T>(),
153
- startsWithInsensitive: all.startsWithInsensitive<T>(),
153
+ startsWithSensitive: all.startsWithSensitive<T>(),
154
154
  endsWith: all.endsWith<T>(),
155
- endsWithInsensitive: all.endsWithInsensitive<T>(),
155
+ endsWithSensitive: all.endsWithSensitive<T>(),
156
156
  });
157
157
 
158
158
  const json = <T>() => ({