diff --git a/src/pg-structure/column.ts b/src/pg-structure/column.ts index 8ab8e69..5086195 100644 --- a/src/pg-structure/column.ts +++ b/src/pg-structure/column.ts @@ -47,14 +47,8 @@ export default class Column extends DbObject { this.arrayDimension = args.arrayDimension || 0; this.defaultWithTypeCast = args.defaultWithTypeCast; this.attributeNumber = args.attributeNumber; - - if (this.type.numericType !== undefined) { - /* istanbul ignore next */ - const maxLimit = this.precision ? 10 ** (this.precision - (this.scale ?? 0)) : undefined; - const minLimit = maxLimit === undefined ? undefined : -maxLimit; - this.minValue = this.isSerial ? 1 : NUMERIC_BOUNDRIES?.[this.type.name]?.min ?? minLimit; - this.maxValue = NUMERIC_BOUNDRIES?.[this.type.name]?.max ?? maxLimit; - } + this.minValue = this.isSerial ? 1 : NUMERIC_BOUNDRIES?.[this.type.name]?.min; + this.maxValue = NUMERIC_BOUNDRIES?.[this.type.name]?.max; } /** @@ -241,12 +235,12 @@ export default class Column extends DbObject { public readonly length?: number; /** - * For integer and exact numeric columns with scale minimum value of the column. + * Minimum value of the column (only for integer types). */ public readonly minValue?: number; /** - * For integer and exact numeric columns with scale maximum value of the column. + * Maximum value of the column (only for integer types). */ public readonly maxValue?: number; diff --git a/test/column.test.ts b/test/column.test.ts index ac4f900..6c49600 100644 --- a/test/column.test.ts +++ b/test/column.test.ts @@ -145,36 +145,12 @@ describe("Column", () => { expect(accountTable.get("id").maxValue).toBe(2147483647); }); - it("should not have minimum value for numeric column without precision.", () => { - expect(typeTable.get("field2_a").minValue).toBe(undefined); + it("should have minimum value for big integer.", () => { + expect(typeTable.get("field12").minValue).toBe(-9223372036854775808); }); - it("should not have maximum value for numeric column without precision.", () => { - expect(typeTable.get("field2_a").maxValue).toBe(undefined); - }); - - it("should have minimum value for numeric column.", () => { - expect(typeTable.get("field2_b").minValue).toBe(-10); - }); - - it("should have maximum value for numeric column.", () => { - expect(typeTable.get("field2_b").maxValue).toBe(10); - }); - - it("should have minimum value for numeric column with only scale but without scale.", () => { - expect(typeTable.get("field2_c").minValue).toBe(-1000); - }); - - it("should have maximum value for numeric column with only scale but without scale.", () => { - expect(typeTable.get("field2_c").maxValue).toBe(1000); - }); - - it("should not have minimum value for floating column.", () => { - expect(typeTable.get("field21").minValue).toBe(undefined); - }); - - it("should nt have maximum value for floating column.", () => { - expect(typeTable.get("field21").maxValue).toBe(undefined); + it("should have maximum value for big integer.", () => { + expect(typeTable.get("field12").maxValue).toBe(9223372036854775807); }); it("should have referencedColumns.", () => {