mirror of
https://github.com/nocobase/nocobase.git
synced 2026-09-19 02:23:00 +08:00
chore: options from raw type (#5327)
This commit is contained in:
@@ -66,6 +66,19 @@ export class DecimalField extends NumberField {
|
||||
get dataType() {
|
||||
return DataTypes.DECIMAL(this.options.precision, this.options.scale);
|
||||
}
|
||||
|
||||
static optionsFromRawType(rawType: string) {
|
||||
// infer precision and scale from rawType
|
||||
// eg: DECIMAL(10, 2)
|
||||
const matches = rawType.match(/DECIMAL\((\d+),\s*(\d+)\)/);
|
||||
|
||||
if (matches) {
|
||||
return {
|
||||
precision: parseInt(matches[1]),
|
||||
scale: parseInt(matches[2]),
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export interface DecimalFieldOptions extends BaseColumnFieldOptions {
|
||||
|
||||
Reference in New Issue
Block a user