Skip to content

Commit 015df61

Browse files
committed
1.3.0 – add BIGINT support, fix DECIMAL mapping, update license year, enhance PGCon/PGUpdate documentation, upgrade @types/pg and peerDependency.
1 parent 0248dab commit 015df61

5 files changed

Lines changed: 41 additions & 18 deletions

File tree

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
BSD 3-Clause License
22

3-
Copyright (c) 2021, GrandlineX
3+
Copyright (c) 2026, GrandlineX
44
All rights reserved.
55

66
Redistribution and use in source and binary forms, with or without

package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@grandlinex/bundle-postgresql",
3-
"version": "1.2.2",
3+
"version": "1.3.0",
44
"description": "",
55
"type": "module",
66
"exports": {
@@ -43,10 +43,12 @@
4343
},
4444
"license": "BSD-3-Clause",
4545
"dependencies": {
46-
"@grandlinex/core": "1.2.0",
4746
"pg": "8.16.3",
4847
"moment": "2.30.1",
49-
"@types/pg": "8.15.6"
48+
"@types/pg": "8.16.0"
49+
},
50+
"peerDependencies": {
51+
"@grandlinex/core": ">=1.3.1"
5052
},
5153
"devDependencies": {
5254
"@types/jest": "29.5.14",

src/class/PGCon.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,17 @@ import {
2929

3030
type PGDBType = Client;
3131

32+
/**
33+
* PGCon is a PostgreSQL database connection implementation that extends {@link CoreDBCon} and implements {@link IDataBase}.
34+
*
35+
* @template K - Core kernel type extending {@link ICoreKernel<any>}
36+
* @template T - Data base type extending {@link IDataBase<any, any>} or null
37+
* @template P - Core client type extending {@link ICoreClient} or null
38+
* @template C - Core cache type extending {@link ICoreCache} or null
39+
* @template X - Core presenter type extending {@link ICorePresenter<any>} or null
40+
* @extends CoreDBCon<PGDBType, QueryResult | null, K, T, P, C, X>
41+
* @implements IDataBase<PGDBType, QueryResult | null, K, T, P, C, X>
42+
*/
3243
export default class PGCon<
3344
K extends ICoreKernel<any> = ICoreKernel<any>,
3445
T extends IDataBase<any, any> | null = any,

src/class/PGUpdate.ts

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
import { CoreDBUpdate, RawQuery, XUtil } from '@grandlinex/core';
22
import PGCon from './PGCon.js';
33

4+
/**
5+
* Abstract helper class for performing database schema updates on PostgreSQL.
6+
*
7+
* Extends {@link CoreDBUpdate} specialized for the {@link PGCon} connection type.
8+
*
9+
* @abstract
10+
*/
411
export default abstract class PGUpdate extends CoreDBUpdate<PGCon> {
512
/**
613
* Initialize a new table in the database.
@@ -12,14 +19,15 @@ export default abstract class PGUpdate extends CoreDBUpdate<PGCon> {
1219
}
1320

1421
/**
15-
* Alter a table to add a new column.
16-
* @param className
17-
* @param columName
18-
* @param type
19-
* @param notNull
20-
* @param defaultValue
21-
* @param deleteDefault
22-
* @protected
22+
* Adds a new column to a database table corresponding to the provided class name.
23+
*
24+
* @param {string} className - The name of the class whose table will be altered. The table name is derived by converting the class name from camelCase to snake_case.
25+
* @param {string} columName - The name of the new column to add.
26+
* @param {string} type - The SQL data type of the new column (e.g., `"INTEGER"`, `"VARCHAR(255)"`).
27+
* @param {boolean} notNull - Whether the new column should be defined as NOT NULL.
28+
* @param {string} [defaultValue] - Optional default value for the new column. If supplied, the default is applied unless `deleteDefault` is true.
29+
* @param {boolean} [deleteDefault] - When true and a default value is supplied, the default is dropped after the column is added.
30+
* @returns {Promise<boolean>} A promise that resolves to `true` if all SQL statements executed successfully, otherwise `false`.
2331
*/
2432
protected async alterTableAddColumn(
2533
className: string,
@@ -60,11 +68,11 @@ export default abstract class PGUpdate extends CoreDBUpdate<PGCon> {
6068
}
6169

6270
/**
63-
* Alter a table to delete a column.
64-
* This method is used to remove a column from an existing table in the database.
65-
* @param className
66-
* @param columName
67-
* @protected
71+
* Deletes a column from the database table that corresponds to the given class name.
72+
*
73+
* @param {string} className The name of the class representing the table. The method converts this name from camelCase to snake_case to derive the actual table name.
74+
* @param {string} columName The name of the column to be removed from the table.
75+
* @returns {Promise<boolean>} A promise that resolves to `true` when the column has been successfully dropped from all executed queries; otherwise it resolves to `false`.
6876
*/
6977
protected async alterTableDeleteColumn(
7078
className: string,

src/util/resolveDBType.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@ export default function resolveDBType(dType: DataType) {
44
switch (dType) {
55
case 'int':
66
return 'INT';
7+
case 'long':
8+
return 'BIGINT';
79
case 'double':
8-
return 'decimal';
10+
return 'DECIMAL';
911
case 'float':
1012
return 'REAL';
1113
case 'blob':

0 commit comments

Comments
 (0)