@proteinjs/db 1.0.29 → 1.1.1

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/test/CrudTests.ts CHANGED
@@ -45,7 +45,7 @@ export class ReservedWordTestTable extends Table<ReservedWordTest> {
45
45
  /**
46
46
  * Used for testing purposes only.
47
47
  * */
48
- export const getTestTable = (tableName: string) => {
48
+ export const getCrudTestTable = (tableName: string) => {
49
49
  const employeeTable = new EmployeeTestTable();
50
50
  if (employeeTable.name == tableName) {
51
51
  return new EmployeeTestTable();
@@ -61,7 +61,7 @@ export const getTestTable = (tableName: string) => {
61
61
 
62
62
  export const crudTests = (driver: DbDriver, dropTable: (table: Table<any>) => Promise<void>) => {
63
63
  return () => {
64
- const db = new Db(driver, getTestTable);
64
+ const db = new Db(driver, getCrudTestTable);
65
65
 
66
66
  beforeAll(async () => {
67
67
  if (driver.start) {
@@ -265,29 +265,29 @@ export const crudTests = (driver: DbDriver, dropTable: (table: Table<any>) => Pr
265
265
  jobTitle: 'Cowboy',
266
266
  startDate: new Date('2016-05-24T00:00:00Z'),
267
267
  };
268
- const employeeTable: Table<Employee> = new EmployeeTestTable();
268
+ const emplyeeTable: Table<Employee> = new EmployeeTestTable();
269
269
 
270
- const insertedEmployee1 = await db.insert(employeeTable, testEmployee1);
271
- const insertedEmployee2 = await db.insert(employeeTable, testEmployee2);
272
- const insertedEmployee3 = await db.insert(employeeTable, testEmployee3);
270
+ const insertedEmployee1 = await db.insert(emplyeeTable, testEmployee1);
271
+ const insertedEmployee2 = await db.insert(emplyeeTable, testEmployee2);
272
+ const insertedEmployee3 = await db.insert(emplyeeTable, testEmployee3);
273
273
 
274
- const betweenQuery = new QueryBuilder<Employee>(employeeTable.name).condition({
274
+ const betweenQuery = new QueryBuilder<Employee>(emplyeeTable.name).condition({
275
275
  field: 'startDate',
276
276
  operator: 'BETWEEN',
277
277
  value: ['2000-06-05T00:00:00Z', '2024-06-05T00:00:00Z'],
278
278
  });
279
- const betweenResults = await db.query(employeeTable, betweenQuery);
279
+ const betweenResults = await db.query(emplyeeTable, betweenQuery);
280
280
  expect(betweenResults.length).toBe(2);
281
281
  expect(betweenResults.some((emp) => emp.name === 'Kiriko')).toBe(true);
282
282
  expect(betweenResults.some((emp) => emp.name === 'Cassidy')).toBe(true);
283
283
 
284
284
  // Clean up
285
- const qb = new QueryBuilder<Employee>(employeeTable.name).condition({
285
+ const qb = new QueryBuilder<Employee>(emplyeeTable.name).condition({
286
286
  field: 'id',
287
287
  operator: 'IN',
288
288
  value: [insertedEmployee1.id, insertedEmployee2.id, insertedEmployee3.id],
289
289
  });
290
- await db.delete(employeeTable, qb);
290
+ await db.delete(emplyeeTable, qb);
291
291
  });
292
292
 
293
293
  test('Query with sort', async () => {
@@ -484,5 +484,38 @@ export const crudTests = (driver: DbDriver, dropTable: (table: Table<any>) => Pr
484
484
  await db.delete(table, { id: insertedRecord1.id });
485
485
  await db.delete(table, { id: insertedRecord2.id });
486
486
  }, 10000);
487
+
488
+ test('Case sensitivity', async () => {
489
+ const testEmployee: Omit<Employee, keyof Record> = {
490
+ name: 'Veronica',
491
+ jobTitle: 'Software ENGINEER',
492
+ isRemote: true,
493
+ startDate: new Date('2024-04-01T00:00:00Z'),
494
+ };
495
+ const emplyeeTable: Table<Employee> = new EmployeeTestTable();
496
+ const insertedEmployee = await db.insert(emplyeeTable, testEmployee);
497
+
498
+ const queryNameInsensitive = new QueryBuilder<Employee>(emplyeeTable.name).condition(
499
+ {
500
+ field: 'jobTitle',
501
+ operator: '=',
502
+ value: 'SOFTWARE engineer',
503
+ },
504
+ undefined,
505
+ false
506
+ );
507
+ const nameResultsIns = await db.query(emplyeeTable, queryNameInsensitive);
508
+ expect(nameResultsIns.length).toBe(1);
509
+
510
+ const queryNameSensitive = new QueryBuilder<Employee>(emplyeeTable.name).condition({
511
+ field: 'jobTitle',
512
+ operator: '=',
513
+ value: 'SOFTWARE ENGINEER',
514
+ });
515
+ const nameResultsSens = await db.query(emplyeeTable, queryNameSensitive);
516
+ expect(nameResultsSens.length).toBe(0);
517
+
518
+ await db.delete(emplyeeTable, { id: insertedEmployee.id });
519
+ });
487
520
  };
488
521
  };
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2023 Brent Bahry
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.