Skip to content

Commit f675eef

Browse files
committed
chore: update module references, fix SQL client release, and improve code formatting
1 parent c80cade commit f675eef

File tree

18 files changed

+80
-50
lines changed

18 files changed

+80
-50
lines changed

.idea/modules.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
provenance=false

__tests__/repository/paginate.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ describe("Repository Pagination", () => {
6060
expect(page.nodes).toHaveLength(5);
6161
for (let i = 1; i < page.nodes.length; i++) {
6262
expect(page.nodes[i].age).toBeGreaterThanOrEqual(
63-
page?.nodes?.[i - 1].age ?? 0
63+
page?.nodes?.[i - 1].age ?? 0,
6464
);
6565
}
6666
});
@@ -75,7 +75,7 @@ describe("Repository Pagination", () => {
7575
expect(page.nodes).toHaveLength(5);
7676
for (let i = 1; i < page.nodes.length; i++) {
7777
expect(page.nodes[i].age ?? 0).toBeLessThanOrEqual(
78-
page.nodes[i - 1].age ?? 0
78+
page.nodes[i - 1].age ?? 0,
7979
);
8080
}
8181
});

examples/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

package.json

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "sqlkit",
3-
"version": "1.0.1",
3+
"version": "1.0.3",
44
"description": "A lightweight SQL builder for TypeScript",
55
"license": "MIT",
66
"author": {
@@ -12,17 +12,15 @@
1212
"url": "https://github.com/sqlkit-dev/sqlkit"
1313
},
1414
"type": "module",
15-
"main": "dist/index.js",
15+
"main": "dist/index.cjs",
1616
"types": "dist/index.d.ts",
1717
"module": "dist/index.mjs",
1818
"scripts": {
19-
"build": "tsup src/index.ts --minify --sourcemap",
20-
"dev": "tsup --watch",
19+
"build": "pkgroll",
20+
"tinker": "npx tsx watch src/tinker.ts",
2121
"test": "jest --runInBand",
22-
"lint": "eslint src --ext .ts",
2322
"format": "prettier --write \"src/**/*.ts\"",
24-
"docs": "npx typedoc src/index.ts",
25-
"prepublishOnly": "npm run build"
23+
"docs": "npx typedoc src/index.ts"
2624
},
2725
"keywords": [
2826
"sql",
@@ -37,8 +35,8 @@
3735
"@types/pg": "^8.11.12",
3836
"jest": "^29.7.0",
3937
"pg": "^8.14.1",
38+
"pkgroll": "^2.12.1",
4039
"prettier": "^3.5.3",
41-
"ts-jest": "^29.3.2",
42-
"tsup": "^8.4.0"
40+
"ts-jest": "^29.3.2"
4341
}
4442
}

src/dialects/postgres.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,15 @@ export class PostgresAdapter implements SqlExecutor {
66
async executeSQL<T>(sql: string, values: any[]): Promise<QueryResult> {
77
try {
88
const result = await this.client.query(sql, values);
9+
this.client.release();
910
return { rows: result.rows as T[] };
1011
} catch (error) {
1112
throw new Error(`PostgreSQL error: ${(error as Error).message}`);
13+
} finally {
14+
// Ensure the client is released back to the pool
15+
if (this.client.release) {
16+
this.client.release();
17+
}
1218
}
1319
}
1420
}

src/index.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
export * from "./query-builder";
21
export * from "./dialects";
3-
export * from "./types";
42
export * from "./operators";
3+
export * from "./query-builder";
4+
export * from "./repository";
55
export * from "./schema";
6+
export * from "./types";
7+
export * from "./utils";

src/operators/comparison.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ export function ilike<T>(key: keyof T, pattern: string): SimpleWhere<T> {
120120
*/
121121
export function inArray<T, K extends keyof T>(
122122
key: K,
123-
values: T[K][]
123+
values: T[K][],
124124
): SimpleWhere<T> {
125125
return {
126126
key,
@@ -137,7 +137,7 @@ export function inArray<T, K extends keyof T>(
137137
*/
138138
export function notInArray<T, K extends keyof T>(
139139
key: K,
140-
values: T[K][]
140+
values: T[K][],
141141
): SimpleWhere<T> {
142142
return {
143143
key,
@@ -182,7 +182,7 @@ export function isNotNull<T>(key: keyof T): SimpleWhere<T> {
182182
export function between<T, K extends keyof T>(
183183
key: K,
184184
min: T[K],
185-
max: T[K]
185+
max: T[K],
186186
): SimpleWhere<T> {
187187
return {
188188
key,

src/query-builder/base.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import {QueryResult, SqlExecutor} from "../types";
1+
import { QueryResult, SqlExecutor } from "../types";
22

33
export abstract class BaseQueryBuilder<T> {
44
protected constructor(
55
protected readonly tableName: string,
6-
protected readonly executor: SqlExecutor
6+
protected readonly executor: SqlExecutor,
77
) {}
88

99
protected abstract build(): { sql: string; values: any[] };

src/query-builder/delete.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export class DeleteQueryBuilder<T> extends BaseQueryBuilder<T> {
2626
build(): { sql: string; values: any[] } {
2727
const { whereClause, values } = buildWhereClause(
2828
this.whereCondition,
29-
this.tableName
29+
this.tableName,
3030
);
3131

3232
const returning = this.returningColumns.join(", ");

0 commit comments

Comments
 (0)