drizzle-orm 1.0.0-beta.1-867d080 → 1.0.0-beta.1-e5790ad
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/mysql-core/columns/decimal.cjs +1 -86
- package/mysql-core/columns/decimal.cjs.map +1 -1
- package/mysql-core/columns/decimal.d.cts +3 -47
- package/mysql-core/columns/decimal.d.ts +3 -47
- package/mysql-core/columns/decimal.js +1 -82
- package/mysql-core/columns/decimal.js.map +1 -1
- package/mysql-core/dialect.cjs +0 -3
- package/mysql-core/dialect.cjs.map +1 -1
- package/mysql-core/dialect.js +0 -3
- package/mysql-core/dialect.js.map +1 -1
- package/neon-http/session.cjs +12 -8
- package/neon-http/session.cjs.map +1 -1
- package/neon-http/session.d.cts +2 -0
- package/neon-http/session.d.ts +2 -0
- package/neon-http/session.js +12 -8
- package/neon-http/session.js.map +1 -1
- package/neon-serverless/session.cjs +0 -6
- package/neon-serverless/session.cjs.map +1 -1
- package/neon-serverless/session.js +0 -6
- package/neon-serverless/session.js.map +1 -1
- package/node-postgres/session.cjs +0 -6
- package/node-postgres/session.cjs.map +1 -1
- package/node-postgres/session.js +0 -6
- package/node-postgres/session.js.map +1 -1
- package/package.json +1 -1
- package/pg-core/columns/numeric.cjs +1 -86
- package/pg-core/columns/numeric.cjs.map +1 -1
- package/pg-core/columns/numeric.d.cts +6 -61
- package/pg-core/columns/numeric.d.ts +6 -61
- package/pg-core/columns/numeric.js +1 -82
- package/pg-core/columns/numeric.js.map +1 -1
- package/pg-core/dialect.cjs +0 -2
- package/pg-core/dialect.cjs.map +1 -1
- package/pg-core/dialect.js +0 -2
- package/pg-core/dialect.js.map +1 -1
- package/pglite/session.cjs +0 -8
- package/pglite/session.cjs.map +1 -1
- package/pglite/session.js +0 -8
- package/pglite/session.js.map +1 -1
- package/postgres-js/driver.cjs +1 -1
- package/postgres-js/driver.cjs.map +1 -1
- package/postgres-js/driver.js +1 -1
- package/postgres-js/driver.js.map +1 -1
- package/sqlite-core/columns/numeric.cjs +2 -64
- package/sqlite-core/columns/numeric.cjs.map +1 -1
- package/sqlite-core/columns/numeric.d.cts +2 -43
- package/sqlite-core/columns/numeric.d.ts +2 -43
- package/sqlite-core/columns/numeric.js +2 -60
- package/sqlite-core/columns/numeric.js.map +1 -1
- package/sqlite-core/dialect.cjs +0 -5
- package/sqlite-core/dialect.cjs.map +1 -1
- package/sqlite-core/dialect.js +0 -5
- package/sqlite-core/dialect.js.map +1 -1
- package/vercel-postgres/session.cjs +0 -6
- package/vercel-postgres/session.cjs.map +1 -1
- package/vercel-postgres/session.js +0 -6
- package/vercel-postgres/session.js.map +1 -1
- package/version.cjs +1 -1
- package/version.d.cts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
|
@@ -19,11 +19,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
19
19
|
var decimal_exports = {};
|
|
20
20
|
__export(decimal_exports, {
|
|
21
21
|
MySqlDecimal: () => MySqlDecimal,
|
|
22
|
-
MySqlDecimalBigInt: () => MySqlDecimalBigInt,
|
|
23
|
-
MySqlDecimalBigIntBuilder: () => MySqlDecimalBigIntBuilder,
|
|
24
22
|
MySqlDecimalBuilder: () => MySqlDecimalBuilder,
|
|
25
|
-
MySqlDecimalNumber: () => MySqlDecimalNumber,
|
|
26
|
-
MySqlDecimalNumberBuilder: () => MySqlDecimalNumberBuilder,
|
|
27
23
|
decimal: () => decimal
|
|
28
24
|
});
|
|
29
25
|
module.exports = __toCommonJS(decimal_exports);
|
|
@@ -69,95 +65,14 @@ class MySqlDecimal extends import_common.MySqlColumnWithAutoIncrement {
|
|
|
69
65
|
return this.unsigned ? `${type} unsigned` : type;
|
|
70
66
|
}
|
|
71
67
|
}
|
|
72
|
-
class MySqlDecimalNumberBuilder extends import_common.MySqlColumnBuilderWithAutoIncrement {
|
|
73
|
-
static [import_entity.entityKind] = "MySqlDecimalNumberBuilder";
|
|
74
|
-
constructor(name, config) {
|
|
75
|
-
super(name, "number", "MySqlDecimalNumber");
|
|
76
|
-
this.config.precision = config?.precision;
|
|
77
|
-
this.config.scale = config?.scale;
|
|
78
|
-
this.config.unsigned = config?.unsigned;
|
|
79
|
-
}
|
|
80
|
-
/** @internal */
|
|
81
|
-
build(table) {
|
|
82
|
-
return new MySqlDecimalNumber(
|
|
83
|
-
table,
|
|
84
|
-
this.config
|
|
85
|
-
);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
class MySqlDecimalNumber extends import_common.MySqlColumnWithAutoIncrement {
|
|
89
|
-
static [import_entity.entityKind] = "MySqlDecimalNumber";
|
|
90
|
-
precision = this.config.precision;
|
|
91
|
-
scale = this.config.scale;
|
|
92
|
-
unsigned = this.config.unsigned;
|
|
93
|
-
mapFromDriverValue(value) {
|
|
94
|
-
if (typeof value === "number")
|
|
95
|
-
return value;
|
|
96
|
-
return Number(value);
|
|
97
|
-
}
|
|
98
|
-
mapToDriverValue = String;
|
|
99
|
-
getSQLType() {
|
|
100
|
-
let type = "";
|
|
101
|
-
if (this.precision !== void 0 && this.scale !== void 0) {
|
|
102
|
-
type += `decimal(${this.precision},${this.scale})`;
|
|
103
|
-
} else if (this.precision === void 0) {
|
|
104
|
-
type += "decimal";
|
|
105
|
-
} else {
|
|
106
|
-
type += `decimal(${this.precision})`;
|
|
107
|
-
}
|
|
108
|
-
type = type === "decimal(10,0)" || type === "decimal(10)" ? "decimal" : type;
|
|
109
|
-
return this.unsigned ? `${type} unsigned` : type;
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
class MySqlDecimalBigIntBuilder extends import_common.MySqlColumnBuilderWithAutoIncrement {
|
|
113
|
-
static [import_entity.entityKind] = "MySqlDecimalBigIntBuilder";
|
|
114
|
-
constructor(name, config) {
|
|
115
|
-
super(name, "bigint", "MySqlDecimalBigInt");
|
|
116
|
-
this.config.precision = config?.precision;
|
|
117
|
-
this.config.scale = config?.scale;
|
|
118
|
-
this.config.unsigned = config?.unsigned;
|
|
119
|
-
}
|
|
120
|
-
/** @internal */
|
|
121
|
-
build(table) {
|
|
122
|
-
return new MySqlDecimalBigInt(
|
|
123
|
-
table,
|
|
124
|
-
this.config
|
|
125
|
-
);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
class MySqlDecimalBigInt extends import_common.MySqlColumnWithAutoIncrement {
|
|
129
|
-
static [import_entity.entityKind] = "MySqlDecimalBigInt";
|
|
130
|
-
precision = this.config.precision;
|
|
131
|
-
scale = this.config.scale;
|
|
132
|
-
unsigned = this.config.unsigned;
|
|
133
|
-
mapFromDriverValue = BigInt;
|
|
134
|
-
mapToDriverValue = String;
|
|
135
|
-
getSQLType() {
|
|
136
|
-
let type = "";
|
|
137
|
-
if (this.precision !== void 0 && this.scale !== void 0) {
|
|
138
|
-
type += `decimal(${this.precision},${this.scale})`;
|
|
139
|
-
} else if (this.precision === void 0) {
|
|
140
|
-
type += "decimal";
|
|
141
|
-
} else {
|
|
142
|
-
type += `decimal(${this.precision})`;
|
|
143
|
-
}
|
|
144
|
-
type = type === "decimal(10,0)" || type === "decimal(10)" ? "decimal" : type;
|
|
145
|
-
return this.unsigned ? `${type} unsigned` : type;
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
68
|
function decimal(a, b = {}) {
|
|
149
69
|
const { name, config } = (0, import_utils.getColumnNameAndConfig)(a, b);
|
|
150
|
-
|
|
151
|
-
return mode === "number" ? new MySqlDecimalNumberBuilder(name, config) : mode === "bigint" ? new MySqlDecimalBigIntBuilder(name, config) : new MySqlDecimalBuilder(name, config);
|
|
70
|
+
return new MySqlDecimalBuilder(name, config);
|
|
152
71
|
}
|
|
153
72
|
// Annotate the CommonJS export names for ESM import in node:
|
|
154
73
|
0 && (module.exports = {
|
|
155
74
|
MySqlDecimal,
|
|
156
|
-
MySqlDecimalBigInt,
|
|
157
|
-
MySqlDecimalBigIntBuilder,
|
|
158
75
|
MySqlDecimalBuilder,
|
|
159
|
-
MySqlDecimalNumber,
|
|
160
|
-
MySqlDecimalNumberBuilder,
|
|
161
76
|
decimal
|
|
162
77
|
});
|
|
163
78
|
//# sourceMappingURL=decimal.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/mysql-core/columns/decimal.ts"],"sourcesContent":["import type { ColumnBuilderBaseConfig, ColumnBuilderRuntimeConfig, MakeColumnConfig } from '~/column-builder.ts';\nimport type { ColumnBaseConfig } from '~/column.ts';\nimport { entityKind } from '~/entity.ts';\nimport type { AnyMySqlTable } from '~/mysql-core/table.ts';\nimport { type Equal, getColumnNameAndConfig } from '~/utils.ts';\nimport { MySqlColumnBuilderWithAutoIncrement, MySqlColumnWithAutoIncrement } from './common.ts';\n\nexport type MySqlDecimalBuilderInitial<TName extends string> = MySqlDecimalBuilder<{\n\tname: TName;\n\tdataType: 'string';\n\tcolumnType: 'MySqlDecimal';\n\tdata: string;\n\tdriverParam: string;\n\tenumValues: undefined;\n}>;\n\nexport class MySqlDecimalBuilder<\n\tT extends ColumnBuilderBaseConfig<'string', 'MySqlDecimal'>,\n> extends MySqlColumnBuilderWithAutoIncrement<T, MySqlDecimalConfig> {\n\tstatic override readonly [entityKind]: string = 'MySqlDecimalBuilder';\n\n\tconstructor(name: T['name'], config: MySqlDecimalConfig | undefined) {\n\t\tsuper(name, 'string', 'MySqlDecimal');\n\t\tthis.config.precision = config?.precision;\n\t\tthis.config.scale = config?.scale;\n\t\tthis.config.unsigned = config?.unsigned;\n\t}\n\n\t/** @internal */\n\toverride build<TTableName extends string>(\n\t\ttable: AnyMySqlTable<{ name: TTableName }>,\n\t): MySqlDecimal<MakeColumnConfig<T, TTableName>> {\n\t\treturn new MySqlDecimal<MakeColumnConfig<T, TTableName>>(\n\t\t\ttable,\n\t\t\tthis.config as ColumnBuilderRuntimeConfig<any, any>,\n\t\t);\n\t}\n}\n\nexport class MySqlDecimal<T extends ColumnBaseConfig<'string', 'MySqlDecimal'>>\n\textends MySqlColumnWithAutoIncrement<T, MySqlDecimalConfig>\n{\n\tstatic override readonly [entityKind]: string = 'MySqlDecimal';\n\n\treadonly precision: number | undefined = this.config.precision;\n\treadonly scale: number | undefined = this.config.scale;\n\treadonly unsigned: boolean | undefined = this.config.unsigned;\n\n\toverride mapFromDriverValue(value: unknown): string {\n\t\t// For RQBv2\n\t\tif (typeof value === 'string') return value;\n\n\t\treturn String(value);\n\t}\n\n\tgetSQLType(): string {\n\t\tlet type = '';\n\t\tif (this.precision !== undefined && this.scale !== undefined) {\n\t\t\ttype += `decimal(${this.precision},${this.scale})`;\n\t\t} else if (this.precision === undefined) {\n\t\t\ttype += 'decimal';\n\t\t} else {\n\t\t\ttype += `decimal(${this.precision})`;\n\t\t}\n\t\ttype = type === 'decimal(10,0)' || type === 'decimal(10)' ? 'decimal' : type;\n\t\treturn this.unsigned ? `${type} unsigned` : type;\n\t}\n}\n\nexport type MySqlDecimalNumberBuilderInitial<TName extends string> = MySqlDecimalNumberBuilder<{\n\tname: TName;\n\tdataType: 'number';\n\tcolumnType: 'MySqlDecimalNumber';\n\tdata: number;\n\tdriverParam: string;\n\tenumValues: undefined;\n}>;\n\nexport class MySqlDecimalNumberBuilder<\n\tT extends ColumnBuilderBaseConfig<'number', 'MySqlDecimalNumber'>,\n> extends MySqlColumnBuilderWithAutoIncrement<T, MySqlDecimalConfig> {\n\tstatic override readonly [entityKind]: string = 'MySqlDecimalNumberBuilder';\n\n\tconstructor(name: T['name'], config: MySqlDecimalConfig | undefined) {\n\t\tsuper(name, 'number', 'MySqlDecimalNumber');\n\t\tthis.config.precision = config?.precision;\n\t\tthis.config.scale = config?.scale;\n\t\tthis.config.unsigned = config?.unsigned;\n\t}\n\n\t/** @internal */\n\toverride build<TTableName extends string>(\n\t\ttable: AnyMySqlTable<{ name: TTableName }>,\n\t): MySqlDecimalNumber<MakeColumnConfig<T, TTableName>> {\n\t\treturn new MySqlDecimalNumber<MakeColumnConfig<T, TTableName>>(\n\t\t\ttable,\n\t\t\tthis.config as ColumnBuilderRuntimeConfig<any, any>,\n\t\t);\n\t}\n}\n\nexport class MySqlDecimalNumber<T extends ColumnBaseConfig<'number', 'MySqlDecimalNumber'>>\n\textends MySqlColumnWithAutoIncrement<T, MySqlDecimalConfig>\n{\n\tstatic override readonly [entityKind]: string = 'MySqlDecimalNumber';\n\n\treadonly precision: number | undefined = this.config.precision;\n\treadonly scale: number | undefined = this.config.scale;\n\treadonly unsigned: boolean | undefined = this.config.unsigned;\n\n\toverride mapFromDriverValue(value: unknown): number {\n\t\tif (typeof value === 'number') return value;\n\n\t\treturn Number(value);\n\t}\n\n\toverride mapToDriverValue = String;\n\n\tgetSQLType(): string {\n\t\tlet type = '';\n\t\tif (this.precision !== undefined && this.scale !== undefined) {\n\t\t\ttype += `decimal(${this.precision},${this.scale})`;\n\t\t} else if (this.precision === undefined) {\n\t\t\ttype += 'decimal';\n\t\t} else {\n\t\t\ttype += `decimal(${this.precision})`;\n\t\t}\n\t\ttype = type === 'decimal(10,0)' || type === 'decimal(10)' ? 'decimal' : type;\n\t\treturn this.unsigned ? `${type} unsigned` : type;\n\t}\n}\n\nexport type MySqlDecimalBigIntBuilderInitial<TName extends string> = MySqlDecimalBigIntBuilder<{\n\tname: TName;\n\tdataType: 'bigint';\n\tcolumnType: 'MySqlDecimalBigInt';\n\tdata: bigint;\n\tdriverParam: string;\n\tenumValues: undefined;\n}>;\n\nexport class MySqlDecimalBigIntBuilder<\n\tT extends ColumnBuilderBaseConfig<'bigint', 'MySqlDecimalBigInt'>,\n> extends MySqlColumnBuilderWithAutoIncrement<T, MySqlDecimalConfig> {\n\tstatic override readonly [entityKind]: string = 'MySqlDecimalBigIntBuilder';\n\n\tconstructor(name: T['name'], config: MySqlDecimalConfig | undefined) {\n\t\tsuper(name, 'bigint', 'MySqlDecimalBigInt');\n\t\tthis.config.precision = config?.precision;\n\t\tthis.config.scale = config?.scale;\n\t\tthis.config.unsigned = config?.unsigned;\n\t}\n\n\t/** @internal */\n\toverride build<TTableName extends string>(\n\t\ttable: AnyMySqlTable<{ name: TTableName }>,\n\t): MySqlDecimalBigInt<MakeColumnConfig<T, TTableName>> {\n\t\treturn new MySqlDecimalBigInt<MakeColumnConfig<T, TTableName>>(\n\t\t\ttable,\n\t\t\tthis.config as ColumnBuilderRuntimeConfig<any, any>,\n\t\t);\n\t}\n}\n\nexport class MySqlDecimalBigInt<T extends ColumnBaseConfig<'bigint', 'MySqlDecimalBigInt'>>\n\textends MySqlColumnWithAutoIncrement<T, MySqlDecimalConfig>\n{\n\tstatic override readonly [entityKind]: string = 'MySqlDecimalBigInt';\n\n\treadonly precision: number | undefined = this.config.precision;\n\treadonly scale: number | undefined = this.config.scale;\n\treadonly unsigned: boolean | undefined = this.config.unsigned;\n\n\toverride mapFromDriverValue = BigInt;\n\n\toverride mapToDriverValue = String;\n\n\tgetSQLType(): string {\n\t\tlet type = '';\n\t\tif (this.precision !== undefined && this.scale !== undefined) {\n\t\t\ttype += `decimal(${this.precision},${this.scale})`;\n\t\t} else if (this.precision === undefined) {\n\t\t\ttype += 'decimal';\n\t\t} else {\n\t\t\ttype += `decimal(${this.precision})`;\n\t\t}\n\t\ttype = type === 'decimal(10,0)' || type === 'decimal(10)' ? 'decimal' : type;\n\t\treturn this.unsigned ? `${type} unsigned` : type;\n\t}\n}\n\nexport interface MySqlDecimalConfig<T extends 'string' | 'number' | 'bigint' = 'string' | 'number' | 'bigint'> {\n\tprecision?: number;\n\tscale?: number;\n\tunsigned?: boolean;\n\tmode?: T;\n}\n\nexport function decimal(): MySqlDecimalBuilderInitial<''>;\nexport function decimal<TMode extends 'string' | 'number' | 'bigint'>(\n\tconfig: MySqlDecimalConfig<TMode>,\n): Equal<TMode, 'number'> extends true ? MySqlDecimalNumberBuilderInitial<''>\n\t: Equal<TMode, 'bigint'> extends true ? MySqlDecimalBigIntBuilderInitial<''>\n\t: MySqlDecimalBuilderInitial<''>;\nexport function decimal<TName extends string, TMode extends 'string' | 'number' | 'bigint'>(\n\tname: TName,\n\tconfig?: MySqlDecimalConfig<TMode>,\n): Equal<TMode, 'number'> extends true ? MySqlDecimalNumberBuilderInitial<TName>\n\t: Equal<TMode, 'bigint'> extends true ? MySqlDecimalBigIntBuilderInitial<TName>\n\t: MySqlDecimalBuilderInitial<TName>;\nexport function decimal(a?: string | MySqlDecimalConfig, b: MySqlDecimalConfig = {}) {\n\tconst { name, config } = getColumnNameAndConfig<MySqlDecimalConfig>(a, b);\n\tconst mode = config?.mode;\n\treturn mode === 'number'\n\t\t? new MySqlDecimalNumberBuilder(name, config)\n\t\t: mode === 'bigint'\n\t\t? new MySqlDecimalBigIntBuilder(name, config)\n\t\t: new MySqlDecimalBuilder(name, config);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,oBAA2B;AAE3B,mBAAmD;AACnD,oBAAkF;AAW3E,MAAM,4BAEH,kDAA2D;AAAA,EACpE,QAA0B,wBAAU,IAAY;AAAA,EAEhD,YAAY,MAAiB,QAAwC;AACpE,UAAM,MAAM,UAAU,cAAc;AACpC,SAAK,OAAO,YAAY,QAAQ;AAChC,SAAK,OAAO,QAAQ,QAAQ;AAC5B,SAAK,OAAO,WAAW,QAAQ;AAAA,EAChC;AAAA;AAAA,EAGS,MACR,OACgD;AAChD,WAAO,IAAI;AAAA,MACV;AAAA,MACA,KAAK;AAAA,IACN;AAAA,EACD;AACD;AAEO,MAAM,qBACJ,2CACT;AAAA,EACC,QAA0B,wBAAU,IAAY;AAAA,EAEvC,YAAgC,KAAK,OAAO;AAAA,EAC5C,QAA4B,KAAK,OAAO;AAAA,EACxC,WAAgC,KAAK,OAAO;AAAA,EAE5C,mBAAmB,OAAwB;AAEnD,QAAI,OAAO,UAAU;AAAU,aAAO;AAEtC,WAAO,OAAO,KAAK;AAAA,EACpB;AAAA,EAEA,aAAqB;AACpB,QAAI,OAAO;AACX,QAAI,KAAK,cAAc,UAAa,KAAK,UAAU,QAAW;AAC7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uilderRuntimeConfig, MakeColumnConfig } from '~/column-builder.ts';\nimport type { ColumnBaseConfig } from '~/column.ts';\nimport { entityKind } from '~/entity.ts';\nimport type { AnyMySqlTable } from '~/mysql-core/table.ts';\nimport { getColumnNameAndConfig } from '~/utils.ts';\nimport { MySqlColumnBuilderWithAutoIncrement, MySqlColumnWithAutoIncrement } from './common.ts';\n\nexport type MySqlDecimalBuilderInitial<TName extends string> = MySqlDecimalBuilder<{\n\tname: TName;\n\tdataType: 'string';\n\tcolumnType: 'MySqlDecimal';\n\tdata: string;\n\tdriverParam: string;\n\tenumValues: undefined;\n}>;\n\nexport class MySqlDecimalBuilder<\n\tT extends ColumnBuilderBaseConfig<'string', 'MySqlDecimal'>,\n> extends MySqlColumnBuilderWithAutoIncrement<T, MySqlDecimalConfig> {\n\tstatic override readonly [entityKind]: string = 'MySqlDecimalBuilder';\n\n\tconstructor(name: T['name'], config: MySqlDecimalConfig | undefined) {\n\t\tsuper(name, 'string', 'MySqlDecimal');\n\t\tthis.config.precision = config?.precision;\n\t\tthis.config.scale = config?.scale;\n\t\tthis.config.unsigned = config?.unsigned;\n\t}\n\n\t/** @internal */\n\toverride build<TTableName extends string>(\n\t\ttable: AnyMySqlTable<{ name: TTableName }>,\n\t): MySqlDecimal<MakeColumnConfig<T, TTableName>> {\n\t\treturn new MySqlDecimal<MakeColumnConfig<T, TTableName>>(\n\t\t\ttable,\n\t\t\tthis.config as ColumnBuilderRuntimeConfig<any, any>,\n\t\t);\n\t}\n}\n\nexport class MySqlDecimal<T extends ColumnBaseConfig<'string', 'MySqlDecimal'>>\n\textends MySqlColumnWithAutoIncrement<T, MySqlDecimalConfig>\n{\n\tstatic override readonly [entityKind]: string = 'MySqlDecimal';\n\n\treadonly precision: number | undefined = this.config.precision;\n\treadonly scale: number | undefined = this.config.scale;\n\treadonly unsigned: boolean | undefined = this.config.unsigned;\n\n\toverride mapFromDriverValue(value: unknown): string {\n\t\t// For RQBv2\n\t\tif (typeof value === 'string') return value;\n\n\t\treturn String(value);\n\t}\n\n\tgetSQLType(): string {\n\t\tlet type = '';\n\t\tif (this.precision !== undefined && this.scale !== undefined) {\n\t\t\ttype += `decimal(${this.precision},${this.scale})`;\n\t\t} else if (this.precision === undefined) {\n\t\t\ttype += 'decimal';\n\t\t} else {\n\t\t\ttype += `decimal(${this.precision})`;\n\t\t}\n\t\ttype = type === 'decimal(10,0)' || type === 'decimal(10)' ? 'decimal' : type;\n\t\treturn this.unsigned ? `${type} unsigned` : type;\n\t}\n}\n\nexport interface MySqlDecimalConfig {\n\tprecision?: number;\n\tscale?: number;\n\tunsigned?: boolean;\n}\n\nexport function decimal(): MySqlDecimalBuilderInitial<''>;\nexport function decimal(\n\tconfig: MySqlDecimalConfig,\n): MySqlDecimalBuilderInitial<''>;\nexport function decimal<TName extends string>(\n\tname: TName,\n\tconfig?: MySqlDecimalConfig,\n): MySqlDecimalBuilderInitial<TName>;\nexport function decimal(a?: string | MySqlDecimalConfig, b: MySqlDecimalConfig = {}) {\n\tconst { name, config } = getColumnNameAndConfig<MySqlDecimalConfig>(a, b);\n\treturn new MySqlDecimalBuilder(name, config);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,oBAA2B;AAE3B,mBAAuC;AACvC,oBAAkF;AAW3E,MAAM,4BAEH,kDAA2D;AAAA,EACpE,QAA0B,wBAAU,IAAY;AAAA,EAEhD,YAAY,MAAiB,QAAwC;AACpE,UAAM,MAAM,UAAU,cAAc;AACpC,SAAK,OAAO,YAAY,QAAQ;AAChC,SAAK,OAAO,QAAQ,QAAQ;AAC5B,SAAK,OAAO,WAAW,QAAQ;AAAA,EAChC;AAAA;AAAA,EAGS,MACR,OACgD;AAChD,WAAO,IAAI;AAAA,MACV;AAAA,MACA,KAAK;AAAA,IACN;AAAA,EACD;AACD;AAEO,MAAM,qBACJ,2CACT;AAAA,EACC,QAA0B,wBAAU,IAAY;AAAA,EAEvC,YAAgC,KAAK,OAAO;AAAA,EAC5C,QAA4B,KAAK,OAAO;AAAA,EACxC,WAAgC,KAAK,OAAO;AAAA,EAE5C,mBAAmB,OAAwB;AAEnD,QAAI,OAAO,UAAU;AAAU,aAAO;AAEtC,WAAO,OAAO,KAAK;AAAA,EACpB;AAAA,EAEA,aAAqB;AACpB,QAAI,OAAO;AACX,QAAI,KAAK,cAAc,UAAa,KAAK,UAAU,QAAW;AAC7D,cAAQ,WAAW,KAAK,SAAS,IAAI,KAAK,KAAK;AAAA,IAChD,WAAW,KAAK,cAAc,QAAW;AACxC,cAAQ;AAAA,IACT,OAAO;AACN,cAAQ,WAAW,KAAK,SAAS;AAAA,IAClC;AACA,WAAO,SAAS,mBAAmB,SAAS,gBAAgB,YAAY;AACxE,WAAO,KAAK,WAAW,GAAG,IAAI,cAAc;AAAA,EAC7C;AACD;AAgBO,SAAS,QAAQ,GAAiC,IAAwB,CAAC,GAAG;AACpF,QAAM,EAAE,MAAM,OAAO,QAAI,qCAA2C,GAAG,CAAC;AACxE,SAAO,IAAI,oBAAoB,MAAM,MAAM;AAC5C;","names":[]}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { ColumnBuilderBaseConfig } from "../../column-builder.cjs";
|
|
2
2
|
import type { ColumnBaseConfig } from "../../column.cjs";
|
|
3
3
|
import { entityKind } from "../../entity.cjs";
|
|
4
|
-
import { type Equal } from "../../utils.cjs";
|
|
5
4
|
import { MySqlColumnBuilderWithAutoIncrement, MySqlColumnWithAutoIncrement } from "./common.cjs";
|
|
6
5
|
export type MySqlDecimalBuilderInitial<TName extends string> = MySqlDecimalBuilder<{
|
|
7
6
|
name: TName;
|
|
@@ -23,54 +22,11 @@ export declare class MySqlDecimal<T extends ColumnBaseConfig<'string', 'MySqlDec
|
|
|
23
22
|
mapFromDriverValue(value: unknown): string;
|
|
24
23
|
getSQLType(): string;
|
|
25
24
|
}
|
|
26
|
-
export
|
|
27
|
-
name: TName;
|
|
28
|
-
dataType: 'number';
|
|
29
|
-
columnType: 'MySqlDecimalNumber';
|
|
30
|
-
data: number;
|
|
31
|
-
driverParam: string;
|
|
32
|
-
enumValues: undefined;
|
|
33
|
-
}>;
|
|
34
|
-
export declare class MySqlDecimalNumberBuilder<T extends ColumnBuilderBaseConfig<'number', 'MySqlDecimalNumber'>> extends MySqlColumnBuilderWithAutoIncrement<T, MySqlDecimalConfig> {
|
|
35
|
-
static readonly [entityKind]: string;
|
|
36
|
-
constructor(name: T['name'], config: MySqlDecimalConfig | undefined);
|
|
37
|
-
}
|
|
38
|
-
export declare class MySqlDecimalNumber<T extends ColumnBaseConfig<'number', 'MySqlDecimalNumber'>> extends MySqlColumnWithAutoIncrement<T, MySqlDecimalConfig> {
|
|
39
|
-
static readonly [entityKind]: string;
|
|
40
|
-
readonly precision: number | undefined;
|
|
41
|
-
readonly scale: number | undefined;
|
|
42
|
-
readonly unsigned: boolean | undefined;
|
|
43
|
-
mapFromDriverValue(value: unknown): number;
|
|
44
|
-
mapToDriverValue: StringConstructor;
|
|
45
|
-
getSQLType(): string;
|
|
46
|
-
}
|
|
47
|
-
export type MySqlDecimalBigIntBuilderInitial<TName extends string> = MySqlDecimalBigIntBuilder<{
|
|
48
|
-
name: TName;
|
|
49
|
-
dataType: 'bigint';
|
|
50
|
-
columnType: 'MySqlDecimalBigInt';
|
|
51
|
-
data: bigint;
|
|
52
|
-
driverParam: string;
|
|
53
|
-
enumValues: undefined;
|
|
54
|
-
}>;
|
|
55
|
-
export declare class MySqlDecimalBigIntBuilder<T extends ColumnBuilderBaseConfig<'bigint', 'MySqlDecimalBigInt'>> extends MySqlColumnBuilderWithAutoIncrement<T, MySqlDecimalConfig> {
|
|
56
|
-
static readonly [entityKind]: string;
|
|
57
|
-
constructor(name: T['name'], config: MySqlDecimalConfig | undefined);
|
|
58
|
-
}
|
|
59
|
-
export declare class MySqlDecimalBigInt<T extends ColumnBaseConfig<'bigint', 'MySqlDecimalBigInt'>> extends MySqlColumnWithAutoIncrement<T, MySqlDecimalConfig> {
|
|
60
|
-
static readonly [entityKind]: string;
|
|
61
|
-
readonly precision: number | undefined;
|
|
62
|
-
readonly scale: number | undefined;
|
|
63
|
-
readonly unsigned: boolean | undefined;
|
|
64
|
-
mapFromDriverValue: BigIntConstructor;
|
|
65
|
-
mapToDriverValue: StringConstructor;
|
|
66
|
-
getSQLType(): string;
|
|
67
|
-
}
|
|
68
|
-
export interface MySqlDecimalConfig<T extends 'string' | 'number' | 'bigint' = 'string' | 'number' | 'bigint'> {
|
|
25
|
+
export interface MySqlDecimalConfig {
|
|
69
26
|
precision?: number;
|
|
70
27
|
scale?: number;
|
|
71
28
|
unsigned?: boolean;
|
|
72
|
-
mode?: T;
|
|
73
29
|
}
|
|
74
30
|
export declare function decimal(): MySqlDecimalBuilderInitial<''>;
|
|
75
|
-
export declare function decimal
|
|
76
|
-
export declare function decimal<TName extends string
|
|
31
|
+
export declare function decimal(config: MySqlDecimalConfig): MySqlDecimalBuilderInitial<''>;
|
|
32
|
+
export declare function decimal<TName extends string>(name: TName, config?: MySqlDecimalConfig): MySqlDecimalBuilderInitial<TName>;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { ColumnBuilderBaseConfig } from "../../column-builder.js";
|
|
2
2
|
import type { ColumnBaseConfig } from "../../column.js";
|
|
3
3
|
import { entityKind } from "../../entity.js";
|
|
4
|
-
import { type Equal } from "../../utils.js";
|
|
5
4
|
import { MySqlColumnBuilderWithAutoIncrement, MySqlColumnWithAutoIncrement } from "./common.js";
|
|
6
5
|
export type MySqlDecimalBuilderInitial<TName extends string> = MySqlDecimalBuilder<{
|
|
7
6
|
name: TName;
|
|
@@ -23,54 +22,11 @@ export declare class MySqlDecimal<T extends ColumnBaseConfig<'string', 'MySqlDec
|
|
|
23
22
|
mapFromDriverValue(value: unknown): string;
|
|
24
23
|
getSQLType(): string;
|
|
25
24
|
}
|
|
26
|
-
export
|
|
27
|
-
name: TName;
|
|
28
|
-
dataType: 'number';
|
|
29
|
-
columnType: 'MySqlDecimalNumber';
|
|
30
|
-
data: number;
|
|
31
|
-
driverParam: string;
|
|
32
|
-
enumValues: undefined;
|
|
33
|
-
}>;
|
|
34
|
-
export declare class MySqlDecimalNumberBuilder<T extends ColumnBuilderBaseConfig<'number', 'MySqlDecimalNumber'>> extends MySqlColumnBuilderWithAutoIncrement<T, MySqlDecimalConfig> {
|
|
35
|
-
static readonly [entityKind]: string;
|
|
36
|
-
constructor(name: T['name'], config: MySqlDecimalConfig | undefined);
|
|
37
|
-
}
|
|
38
|
-
export declare class MySqlDecimalNumber<T extends ColumnBaseConfig<'number', 'MySqlDecimalNumber'>> extends MySqlColumnWithAutoIncrement<T, MySqlDecimalConfig> {
|
|
39
|
-
static readonly [entityKind]: string;
|
|
40
|
-
readonly precision: number | undefined;
|
|
41
|
-
readonly scale: number | undefined;
|
|
42
|
-
readonly unsigned: boolean | undefined;
|
|
43
|
-
mapFromDriverValue(value: unknown): number;
|
|
44
|
-
mapToDriverValue: StringConstructor;
|
|
45
|
-
getSQLType(): string;
|
|
46
|
-
}
|
|
47
|
-
export type MySqlDecimalBigIntBuilderInitial<TName extends string> = MySqlDecimalBigIntBuilder<{
|
|
48
|
-
name: TName;
|
|
49
|
-
dataType: 'bigint';
|
|
50
|
-
columnType: 'MySqlDecimalBigInt';
|
|
51
|
-
data: bigint;
|
|
52
|
-
driverParam: string;
|
|
53
|
-
enumValues: undefined;
|
|
54
|
-
}>;
|
|
55
|
-
export declare class MySqlDecimalBigIntBuilder<T extends ColumnBuilderBaseConfig<'bigint', 'MySqlDecimalBigInt'>> extends MySqlColumnBuilderWithAutoIncrement<T, MySqlDecimalConfig> {
|
|
56
|
-
static readonly [entityKind]: string;
|
|
57
|
-
constructor(name: T['name'], config: MySqlDecimalConfig | undefined);
|
|
58
|
-
}
|
|
59
|
-
export declare class MySqlDecimalBigInt<T extends ColumnBaseConfig<'bigint', 'MySqlDecimalBigInt'>> extends MySqlColumnWithAutoIncrement<T, MySqlDecimalConfig> {
|
|
60
|
-
static readonly [entityKind]: string;
|
|
61
|
-
readonly precision: number | undefined;
|
|
62
|
-
readonly scale: number | undefined;
|
|
63
|
-
readonly unsigned: boolean | undefined;
|
|
64
|
-
mapFromDriverValue: BigIntConstructor;
|
|
65
|
-
mapToDriverValue: StringConstructor;
|
|
66
|
-
getSQLType(): string;
|
|
67
|
-
}
|
|
68
|
-
export interface MySqlDecimalConfig<T extends 'string' | 'number' | 'bigint' = 'string' | 'number' | 'bigint'> {
|
|
25
|
+
export interface MySqlDecimalConfig {
|
|
69
26
|
precision?: number;
|
|
70
27
|
scale?: number;
|
|
71
28
|
unsigned?: boolean;
|
|
72
|
-
mode?: T;
|
|
73
29
|
}
|
|
74
30
|
export declare function decimal(): MySqlDecimalBuilderInitial<''>;
|
|
75
|
-
export declare function decimal
|
|
76
|
-
export declare function decimal<TName extends string
|
|
31
|
+
export declare function decimal(config: MySqlDecimalConfig): MySqlDecimalBuilderInitial<''>;
|
|
32
|
+
export declare function decimal<TName extends string>(name: TName, config?: MySqlDecimalConfig): MySqlDecimalBuilderInitial<TName>;
|
|
@@ -40,94 +40,13 @@ class MySqlDecimal extends MySqlColumnWithAutoIncrement {
|
|
|
40
40
|
return this.unsigned ? `${type} unsigned` : type;
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
|
-
class MySqlDecimalNumberBuilder extends MySqlColumnBuilderWithAutoIncrement {
|
|
44
|
-
static [entityKind] = "MySqlDecimalNumberBuilder";
|
|
45
|
-
constructor(name, config) {
|
|
46
|
-
super(name, "number", "MySqlDecimalNumber");
|
|
47
|
-
this.config.precision = config?.precision;
|
|
48
|
-
this.config.scale = config?.scale;
|
|
49
|
-
this.config.unsigned = config?.unsigned;
|
|
50
|
-
}
|
|
51
|
-
/** @internal */
|
|
52
|
-
build(table) {
|
|
53
|
-
return new MySqlDecimalNumber(
|
|
54
|
-
table,
|
|
55
|
-
this.config
|
|
56
|
-
);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
class MySqlDecimalNumber extends MySqlColumnWithAutoIncrement {
|
|
60
|
-
static [entityKind] = "MySqlDecimalNumber";
|
|
61
|
-
precision = this.config.precision;
|
|
62
|
-
scale = this.config.scale;
|
|
63
|
-
unsigned = this.config.unsigned;
|
|
64
|
-
mapFromDriverValue(value) {
|
|
65
|
-
if (typeof value === "number")
|
|
66
|
-
return value;
|
|
67
|
-
return Number(value);
|
|
68
|
-
}
|
|
69
|
-
mapToDriverValue = String;
|
|
70
|
-
getSQLType() {
|
|
71
|
-
let type = "";
|
|
72
|
-
if (this.precision !== void 0 && this.scale !== void 0) {
|
|
73
|
-
type += `decimal(${this.precision},${this.scale})`;
|
|
74
|
-
} else if (this.precision === void 0) {
|
|
75
|
-
type += "decimal";
|
|
76
|
-
} else {
|
|
77
|
-
type += `decimal(${this.precision})`;
|
|
78
|
-
}
|
|
79
|
-
type = type === "decimal(10,0)" || type === "decimal(10)" ? "decimal" : type;
|
|
80
|
-
return this.unsigned ? `${type} unsigned` : type;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
class MySqlDecimalBigIntBuilder extends MySqlColumnBuilderWithAutoIncrement {
|
|
84
|
-
static [entityKind] = "MySqlDecimalBigIntBuilder";
|
|
85
|
-
constructor(name, config) {
|
|
86
|
-
super(name, "bigint", "MySqlDecimalBigInt");
|
|
87
|
-
this.config.precision = config?.precision;
|
|
88
|
-
this.config.scale = config?.scale;
|
|
89
|
-
this.config.unsigned = config?.unsigned;
|
|
90
|
-
}
|
|
91
|
-
/** @internal */
|
|
92
|
-
build(table) {
|
|
93
|
-
return new MySqlDecimalBigInt(
|
|
94
|
-
table,
|
|
95
|
-
this.config
|
|
96
|
-
);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
class MySqlDecimalBigInt extends MySqlColumnWithAutoIncrement {
|
|
100
|
-
static [entityKind] = "MySqlDecimalBigInt";
|
|
101
|
-
precision = this.config.precision;
|
|
102
|
-
scale = this.config.scale;
|
|
103
|
-
unsigned = this.config.unsigned;
|
|
104
|
-
mapFromDriverValue = BigInt;
|
|
105
|
-
mapToDriverValue = String;
|
|
106
|
-
getSQLType() {
|
|
107
|
-
let type = "";
|
|
108
|
-
if (this.precision !== void 0 && this.scale !== void 0) {
|
|
109
|
-
type += `decimal(${this.precision},${this.scale})`;
|
|
110
|
-
} else if (this.precision === void 0) {
|
|
111
|
-
type += "decimal";
|
|
112
|
-
} else {
|
|
113
|
-
type += `decimal(${this.precision})`;
|
|
114
|
-
}
|
|
115
|
-
type = type === "decimal(10,0)" || type === "decimal(10)" ? "decimal" : type;
|
|
116
|
-
return this.unsigned ? `${type} unsigned` : type;
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
43
|
function decimal(a, b = {}) {
|
|
120
44
|
const { name, config } = getColumnNameAndConfig(a, b);
|
|
121
|
-
|
|
122
|
-
return mode === "number" ? new MySqlDecimalNumberBuilder(name, config) : mode === "bigint" ? new MySqlDecimalBigIntBuilder(name, config) : new MySqlDecimalBuilder(name, config);
|
|
45
|
+
return new MySqlDecimalBuilder(name, config);
|
|
123
46
|
}
|
|
124
47
|
export {
|
|
125
48
|
MySqlDecimal,
|
|
126
|
-
MySqlDecimalBigInt,
|
|
127
|
-
MySqlDecimalBigIntBuilder,
|
|
128
49
|
MySqlDecimalBuilder,
|
|
129
|
-
MySqlDecimalNumber,
|
|
130
|
-
MySqlDecimalNumberBuilder,
|
|
131
50
|
decimal
|
|
132
51
|
};
|
|
133
52
|
//# sourceMappingURL=decimal.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/mysql-core/columns/decimal.ts"],"sourcesContent":["import type { ColumnBuilderBaseConfig, ColumnBuilderRuntimeConfig, MakeColumnConfig } from '~/column-builder.ts';\nimport type { ColumnBaseConfig } from '~/column.ts';\nimport { entityKind } from '~/entity.ts';\nimport type { AnyMySqlTable } from '~/mysql-core/table.ts';\nimport { type Equal, getColumnNameAndConfig } from '~/utils.ts';\nimport { MySqlColumnBuilderWithAutoIncrement, MySqlColumnWithAutoIncrement } from './common.ts';\n\nexport type MySqlDecimalBuilderInitial<TName extends string> = MySqlDecimalBuilder<{\n\tname: TName;\n\tdataType: 'string';\n\tcolumnType: 'MySqlDecimal';\n\tdata: string;\n\tdriverParam: string;\n\tenumValues: undefined;\n}>;\n\nexport class MySqlDecimalBuilder<\n\tT extends ColumnBuilderBaseConfig<'string', 'MySqlDecimal'>,\n> extends MySqlColumnBuilderWithAutoIncrement<T, MySqlDecimalConfig> {\n\tstatic override readonly [entityKind]: string = 'MySqlDecimalBuilder';\n\n\tconstructor(name: T['name'], config: MySqlDecimalConfig | undefined) {\n\t\tsuper(name, 'string', 'MySqlDecimal');\n\t\tthis.config.precision = config?.precision;\n\t\tthis.config.scale = config?.scale;\n\t\tthis.config.unsigned = config?.unsigned;\n\t}\n\n\t/** @internal */\n\toverride build<TTableName extends string>(\n\t\ttable: AnyMySqlTable<{ name: TTableName }>,\n\t): MySqlDecimal<MakeColumnConfig<T, TTableName>> {\n\t\treturn new MySqlDecimal<MakeColumnConfig<T, TTableName>>(\n\t\t\ttable,\n\t\t\tthis.config as ColumnBuilderRuntimeConfig<any, any>,\n\t\t);\n\t}\n}\n\nexport class MySqlDecimal<T extends ColumnBaseConfig<'string', 'MySqlDecimal'>>\n\textends MySqlColumnWithAutoIncrement<T, MySqlDecimalConfig>\n{\n\tstatic override readonly [entityKind]: string = 'MySqlDecimal';\n\n\treadonly precision: number | undefined = this.config.precision;\n\treadonly scale: number | undefined = this.config.scale;\n\treadonly unsigned: boolean | undefined = this.config.unsigned;\n\n\toverride mapFromDriverValue(value: unknown): string {\n\t\t// For RQBv2\n\t\tif (typeof value === 'string') return value;\n\n\t\treturn String(value);\n\t}\n\n\tgetSQLType(): string {\n\t\tlet type = '';\n\t\tif (this.precision !== undefined && this.scale !== undefined) {\n\t\t\ttype += `decimal(${this.precision},${this.scale})`;\n\t\t} else if (this.precision === undefined) {\n\t\t\ttype += 'decimal';\n\t\t} else {\n\t\t\ttype += `decimal(${this.precision})`;\n\t\t}\n\t\ttype = type === 'decimal(10,0)' || type === 'decimal(10)' ? 'decimal' : type;\n\t\treturn this.unsigned ? `${type} unsigned` : type;\n\t}\n}\n\nexport type MySqlDecimalNumberBuilderInitial<TName extends string> = MySqlDecimalNumberBuilder<{\n\tname: TName;\n\tdataType: 'number';\n\tcolumnType: 'MySqlDecimalNumber';\n\tdata: number;\n\tdriverParam: string;\n\tenumValues: undefined;\n}>;\n\nexport class MySqlDecimalNumberBuilder<\n\tT extends ColumnBuilderBaseConfig<'number', 'MySqlDecimalNumber'>,\n> extends MySqlColumnBuilderWithAutoIncrement<T, MySqlDecimalConfig> {\n\tstatic override readonly [entityKind]: string = 'MySqlDecimalNumberBuilder';\n\n\tconstructor(name: T['name'], config: MySqlDecimalConfig | undefined) {\n\t\tsuper(name, 'number', 'MySqlDecimalNumber');\n\t\tthis.config.precision = config?.precision;\n\t\tthis.config.scale = config?.scale;\n\t\tthis.config.unsigned = config?.unsigned;\n\t}\n\n\t/** @internal */\n\toverride build<TTableName extends string>(\n\t\ttable: AnyMySqlTable<{ name: TTableName }>,\n\t): MySqlDecimalNumber<MakeColumnConfig<T, TTableName>> {\n\t\treturn new MySqlDecimalNumber<MakeColumnConfig<T, TTableName>>(\n\t\t\ttable,\n\t\t\tthis.config as ColumnBuilderRuntimeConfig<any, any>,\n\t\t);\n\t}\n}\n\nexport class MySqlDecimalNumber<T extends ColumnBaseConfig<'number', 'MySqlDecimalNumber'>>\n\textends MySqlColumnWithAutoIncrement<T, MySqlDecimalConfig>\n{\n\tstatic override readonly [entityKind]: string = 'MySqlDecimalNumber';\n\n\treadonly precision: number | undefined = this.config.precision;\n\treadonly scale: number | undefined = this.config.scale;\n\treadonly unsigned: boolean | undefined = this.config.unsigned;\n\n\toverride mapFromDriverValue(value: unknown): number {\n\t\tif (typeof value === 'number') return value;\n\n\t\treturn Number(value);\n\t}\n\n\toverride mapToDriverValue = String;\n\n\tgetSQLType(): string {\n\t\tlet type = '';\n\t\tif (this.precision !== undefined && this.scale !== undefined) {\n\t\t\ttype += `decimal(${this.precision},${this.scale})`;\n\t\t} else if (this.precision === undefined) {\n\t\t\ttype += 'decimal';\n\t\t} else {\n\t\t\ttype += `decimal(${this.precision})`;\n\t\t}\n\t\ttype = type === 'decimal(10,0)' || type === 'decimal(10)' ? 'decimal' : type;\n\t\treturn this.unsigned ? `${type} unsigned` : type;\n\t}\n}\n\nexport type MySqlDecimalBigIntBuilderInitial<TName extends string> = MySqlDecimalBigIntBuilder<{\n\tname: TName;\n\tdataType: 'bigint';\n\tcolumnType: 'MySqlDecimalBigInt';\n\tdata: bigint;\n\tdriverParam: string;\n\tenumValues: undefined;\n}>;\n\nexport class MySqlDecimalBigIntBuilder<\n\tT extends ColumnBuilderBaseConfig<'bigint', 'MySqlDecimalBigInt'>,\n> extends MySqlColumnBuilderWithAutoIncrement<T, MySqlDecimalConfig> {\n\tstatic override readonly [entityKind]: string = 'MySqlDecimalBigIntBuilder';\n\n\tconstructor(name: T['name'], config: MySqlDecimalConfig | undefined) {\n\t\tsuper(name, 'bigint', 'MySqlDecimalBigInt');\n\t\tthis.config.precision = config?.precision;\n\t\tthis.config.scale = config?.scale;\n\t\tthis.config.unsigned = config?.unsigned;\n\t}\n\n\t/** @internal */\n\toverride build<TTableName extends string>(\n\t\ttable: AnyMySqlTable<{ name: TTableName }>,\n\t): MySqlDecimalBigInt<MakeColumnConfig<T, TTableName>> {\n\t\treturn new MySqlDecimalBigInt<MakeColumnConfig<T, TTableName>>(\n\t\t\ttable,\n\t\t\tthis.config as ColumnBuilderRuntimeConfig<any, any>,\n\t\t);\n\t}\n}\n\nexport class MySqlDecimalBigInt<T extends ColumnBaseConfig<'bigint', 'MySqlDecimalBigInt'>>\n\textends MySqlColumnWithAutoIncrement<T, MySqlDecimalConfig>\n{\n\tstatic override readonly [entityKind]: string = 'MySqlDecimalBigInt';\n\n\treadonly precision: number | undefined = this.config.precision;\n\treadonly scale: number | undefined = this.config.scale;\n\treadonly unsigned: boolean | undefined = this.config.unsigned;\n\n\toverride mapFromDriverValue = BigInt;\n\n\toverride mapToDriverValue = String;\n\n\tgetSQLType(): string {\n\t\tlet type = '';\n\t\tif (this.precision !== undefined && this.scale !== undefined) {\n\t\t\ttype += `decimal(${this.precision},${this.scale})`;\n\t\t} else if (this.precision === undefined) {\n\t\t\ttype += 'decimal';\n\t\t} else {\n\t\t\ttype += `decimal(${this.precision})`;\n\t\t}\n\t\ttype = type === 'decimal(10,0)' || type === 'decimal(10)' ? 'decimal' : type;\n\t\treturn this.unsigned ? `${type} unsigned` : type;\n\t}\n}\n\nexport interface MySqlDecimalConfig<T extends 'string' | 'number' | 'bigint' = 'string' | 'number' | 'bigint'> {\n\tprecision?: number;\n\tscale?: number;\n\tunsigned?: boolean;\n\tmode?: T;\n}\n\nexport function decimal(): MySqlDecimalBuilderInitial<''>;\nexport function decimal<TMode extends 'string' | 'number' | 'bigint'>(\n\tconfig: MySqlDecimalConfig<TMode>,\n): Equal<TMode, 'number'> extends true ? MySqlDecimalNumberBuilderInitial<''>\n\t: Equal<TMode, 'bigint'> extends true ? MySqlDecimalBigIntBuilderInitial<''>\n\t: MySqlDecimalBuilderInitial<''>;\nexport function decimal<TName extends string, TMode extends 'string' | 'number' | 'bigint'>(\n\tname: TName,\n\tconfig?: MySqlDecimalConfig<TMode>,\n): Equal<TMode, 'number'> extends true ? MySqlDecimalNumberBuilderInitial<TName>\n\t: Equal<TMode, 'bigint'> extends true ? MySqlDecimalBigIntBuilderInitial<TName>\n\t: MySqlDecimalBuilderInitial<TName>;\nexport function decimal(a?: string | MySqlDecimalConfig, b: MySqlDecimalConfig = {}) {\n\tconst { name, config } = getColumnNameAndConfig<MySqlDecimalConfig>(a, b);\n\tconst mode = config?.mode;\n\treturn mode === 'number'\n\t\t? new MySqlDecimalNumberBuilder(name, config)\n\t\t: mode === 'bigint'\n\t\t? new MySqlDecimalBigIntBuilder(name, config)\n\t\t: new MySqlDecimalBuilder(name, config);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,OAAO;AAAA,EAE5C,qBAAqB;AAAA,EAErB,mBAAmB;AAAA,EAE5B,aAAqB;AACpB,QAAI,OAAO;AACX,QAAI,KAAK,cAAc,UAAa,KAAK,UAAU,QAAW;AAC7D,cAAQ,WAAW,KAAK,SAAS,IAAI,KAAK,KAAK;AAAA,IAChD,WAAW,KAAK,cAAc,QAAW;AACxC,cAAQ;AAAA,IACT,OAAO;AACN,cAAQ,WAAW,KAAK,SAAS;AAAA,IAClC;AACA,WAAO,SAAS,mBAAmB,SAAS,gBAAgB,YAAY;AACxE,WAAO,KAAK,WAAW,GAAG,IAAI,cAAc;AAAA,EAC7C;AACD;AAqBO,SAAS,QAAQ,GAAiC,IAAwB,CAAC,GAAG;AACpF,QAAM,EAAE,MAAM,OAAO,IAAI,uBAA2C,GAAG,CAAC;AACxE,QAAM,OAAO,QAAQ;AACrB,SAAO,SAAS,WACb,IAAI,0BAA0B,MAAM,MAAM,IAC1C,SAAS,WACT,IAAI,0BAA0B,MAAM,MAAM,IAC1C,IAAI,oBAAoB,MAAM,MAAM;AACxC;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../src/mysql-core/columns/decimal.ts"],"sourcesContent":["import type { ColumnBuilderBaseConfig, ColumnBuilderRuntimeConfig, MakeColumnConfig } from '~/column-builder.ts';\nimport type { ColumnBaseConfig } from '~/column.ts';\nimport { entityKind } from '~/entity.ts';\nimport type { AnyMySqlTable } from '~/mysql-core/table.ts';\nimport { getColumnNameAndConfig } from '~/utils.ts';\nimport { MySqlColumnBuilderWithAutoIncrement, MySqlColumnWithAutoIncrement } from './common.ts';\n\nexport type MySqlDecimalBuilderInitial<TName extends string> = MySqlDecimalBuilder<{\n\tname: TName;\n\tdataType: 'string';\n\tcolumnType: 'MySqlDecimal';\n\tdata: string;\n\tdriverParam: string;\n\tenumValues: undefined;\n}>;\n\nexport class MySqlDecimalBuilder<\n\tT extends ColumnBuilderBaseConfig<'string', 'MySqlDecimal'>,\n> extends MySqlColumnBuilderWithAutoIncrement<T, MySqlDecimalConfig> {\n\tstatic override readonly [entityKind]: string = 'MySqlDecimalBuilder';\n\n\tconstructor(name: T['name'], config: MySqlDecimalConfig | undefined) {\n\t\tsuper(name, 'string', 'MySqlDecimal');\n\t\tthis.config.precision = config?.precision;\n\t\tthis.config.scale = config?.scale;\n\t\tthis.config.unsigned = config?.unsigned;\n\t}\n\n\t/** @internal */\n\toverride build<TTableName extends string>(\n\t\ttable: AnyMySqlTable<{ name: TTableName }>,\n\t): MySqlDecimal<MakeColumnConfig<T, TTableName>> {\n\t\treturn new MySqlDecimal<MakeColumnConfig<T, TTableName>>(\n\t\t\ttable,\n\t\t\tthis.config as ColumnBuilderRuntimeConfig<any, any>,\n\t\t);\n\t}\n}\n\nexport class MySqlDecimal<T extends ColumnBaseConfig<'string', 'MySqlDecimal'>>\n\textends MySqlColumnWithAutoIncrement<T, MySqlDecimalConfig>\n{\n\tstatic override readonly [entityKind]: string = 'MySqlDecimal';\n\n\treadonly precision: number | undefined = this.config.precision;\n\treadonly scale: number | undefined = this.config.scale;\n\treadonly unsigned: boolean | undefined = this.config.unsigned;\n\n\toverride mapFromDriverValue(value: unknown): string {\n\t\t// For RQBv2\n\t\tif (typeof value === 'string') return value;\n\n\t\treturn String(value);\n\t}\n\n\tgetSQLType(): string {\n\t\tlet type = '';\n\t\tif (this.precision !== undefined && this.scale !== undefined) {\n\t\t\ttype += `decimal(${this.precision},${this.scale})`;\n\t\t} else if (this.precision === undefined) {\n\t\t\ttype += 'decimal';\n\t\t} else {\n\t\t\ttype += `decimal(${this.precision})`;\n\t\t}\n\t\ttype = type === 'decimal(10,0)' || type === 'decimal(10)' ? 'decimal' : type;\n\t\treturn this.unsigned ? `${type} unsigned` : type;\n\t}\n}\n\nexport interface MySqlDecimalConfig {\n\tprecision?: number;\n\tscale?: number;\n\tunsigned?: boolean;\n}\n\nexport function decimal(): MySqlDecimalBuilderInitial<''>;\nexport function decimal(\n\tconfig: MySqlDecimalConfig,\n): MySqlDecimalBuilderInitial<''>;\nexport function decimal<TName extends string>(\n\tname: TName,\n\tconfig?: MySqlDecimalConfig,\n): MySqlDecimalBuilderInitial<TName>;\nexport function decimal(a?: string | MySqlDecimalConfig, b: MySqlDecimalConfig = {}) {\n\tconst { name, config } = getColumnNameAndConfig<MySqlDecimalConfig>(a, b);\n\treturn new MySqlDecimalBuilder(name, config);\n}\n"],"mappings":"AAEA,SAAS,kBAAkB;AAE3B,SAAS,8BAA8B;AACvC,SAAS,qCAAqC,oCAAoC;AAW3E,MAAM,4BAEH,oCAA2D;AAAA,EACpE,QAA0B,UAAU,IAAY;AAAA,EAEhD,YAAY,MAAiB,QAAwC;AACpE,UAAM,MAAM,UAAU,cAAc;AACpC,SAAK,OAAO,YAAY,QAAQ;AAChC,SAAK,OAAO,QAAQ,QAAQ;AAC5B,SAAK,OAAO,WAAW,QAAQ;AAAA,EAChC;AAAA;AAAA,EAGS,MACR,OACgD;AAChD,WAAO,IAAI;AAAA,MACV;AAAA,MACA,KAAK;AAAA,IACN;AAAA,EACD;AACD;AAEO,MAAM,qBACJ,6BACT;AAAA,EACC,QAA0B,UAAU,IAAY;AAAA,EAEvC,YAAgC,KAAK,OAAO;AAAA,EAC5C,QAA4B,KAAK,OAAO;AAAA,EACxC,WAAgC,KAAK,OAAO;AAAA,EAE5C,mBAAmB,OAAwB;AAEnD,QAAI,OAAO,UAAU;AAAU,aAAO;AAEtC,WAAO,OAAO,KAAK;AAAA,EACpB;AAAA,EAEA,aAAqB;AACpB,QAAI,OAAO;AACX,QAAI,KAAK,cAAc,UAAa,KAAK,UAAU,QAAW;AAC7D,cAAQ,WAAW,KAAK,SAAS,IAAI,KAAK,KAAK;AAAA,IAChD,WAAW,KAAK,cAAc,QAAW;AACxC,cAAQ;AAAA,IACT,OAAO;AACN,cAAQ,WAAW,KAAK,SAAS;AAAA,IAClC;AACA,WAAO,SAAS,mBAAmB,SAAS,gBAAgB,YAAY;AACxE,WAAO,KAAK,WAAW,GAAG,IAAI,cAAc;AAAA,EAC7C;AACD;AAgBO,SAAS,QAAQ,GAAiC,IAAwB,CAAC,GAAG;AACpF,QAAM,EAAE,MAAM,OAAO,IAAI,uBAA2C,GAAG,CAAC;AACxE,SAAO,IAAI,oBAAoB,MAAM,MAAM;AAC5C;","names":[]}
|
package/mysql-core/dialect.cjs
CHANGED
|
@@ -875,9 +875,6 @@ class MySqlDialect {
|
|
|
875
875
|
case "MySqlDateTimeString":
|
|
876
876
|
case "MySqlTimestampString":
|
|
877
877
|
case "MySqlFloat":
|
|
878
|
-
case "MySqlDecimal":
|
|
879
|
-
case "MySqlDecimalNumber":
|
|
880
|
-
case "MySqlDecimalBigInt":
|
|
881
878
|
case "MySqlBigInt64": {
|
|
882
879
|
return import_sql.sql`cast(${name} as char) as ${import_sql.sql.identifier(key)}`;
|
|
883
880
|
}
|