@mikro-orm/sql
Advanced tools
+2
-2
| { | ||
| "name": "@mikro-orm/sql", | ||
| "version": "7.1.12-dev.4", | ||
| "version": "7.1.12-dev.5", | ||
| "description": "TypeScript ORM for Node.js based on Data Mapper, Unit of Work and Identity Map patterns. Supports MongoDB, MySQL, PostgreSQL and SQLite databases as well as usage with vanilla JavaScript.", | ||
@@ -56,3 +56,3 @@ "keywords": [ | ||
| "peerDependencies": { | ||
| "@mikro-orm/core": "7.1.12-dev.4" | ||
| "@mikro-orm/core": "7.1.12-dev.5" | ||
| }, | ||
@@ -59,0 +59,0 @@ "engines": { |
@@ -1033,4 +1033,8 @@ import { DecimalType, EntitySchema, isRaw, ReferenceKind, t, Type, UnknownType, Utils, } from '@mikro-orm/core'; | ||
| let defaultValue = c.default ?? null; | ||
| if (defaultValue != null && c.mappedType instanceof DecimalType && Number.isFinite(+defaultValue)) { | ||
| defaultValue = this.#platform.formatDecimal(defaultValue, c.scale).toString(); | ||
| if (defaultValue != null && c.mappedType instanceof DecimalType) { | ||
| // string defaults like `default: '0.00'` are quoted in metadata, so strip the quotes first | ||
| const unquoted = defaultValue.replace(/^'(.*)'$/, '$1'); | ||
| if (Number.isFinite(+unquoted)) { | ||
| defaultValue = this.#platform.formatDecimal(unquoted, c.scale).toString(); | ||
| } | ||
| } | ||
@@ -1037,0 +1041,0 @@ const normalized = { |
@@ -92,2 +92,3 @@ import { type Dictionary } from '@mikro-orm/core'; | ||
| parseJsonDefault(defaultValue?: string | null): Dictionary | string | null; | ||
| private parseDecimalDefault; | ||
| hasSameDefaultValue(from: Column, to: Column): boolean; | ||
@@ -94,0 +95,0 @@ private mapColumnToProperty; |
@@ -996,2 +996,6 @@ import { ArrayType, BooleanType, DateTimeType, DecimalType, inspect, JsonType, parseJsonSafe, Utils, } from '@mikro-orm/core'; | ||
| } | ||
| parseDecimalDefault(defaultValue) { | ||
| const value = +('' + defaultValue).replace(/^'(.+)'$/, '$1'); | ||
| return Number.isFinite(value) ? value : null; | ||
| } | ||
| hasSameDefaultValue(from, to) { | ||
@@ -1022,6 +1026,11 @@ if (from.default == null || | ||
| } | ||
| // mysql stores decimal defaults padded to scale (`0` → `0.00`); compare numerically so the | ||
| // entity-side raw literal and the introspected padded form don't churn the no-op migration | ||
| if (to.mappedType instanceof DecimalType && Number.isFinite(+from.default) && Number.isFinite(+to.default)) { | ||
| return (this.#platform.formatDecimal(from.default, to.scale) === this.#platform.formatDecimal(to.default, to.scale)); | ||
| // mysql pads decimal defaults to scale (`0` → `0.00`) and postgres reports them unquoted | ||
| // while metadata keeps them quoted; compare numerically so neither churns a no-op migration | ||
| if (to.mappedType instanceof DecimalType) { | ||
| const defaultValueFrom = this.parseDecimalDefault(from.default); | ||
| const defaultValueTo = this.parseDecimalDefault(to.default); | ||
| if (defaultValueFrom != null && defaultValueTo != null) { | ||
| return (this.#platform.formatDecimal(defaultValueFrom, to.scale) === | ||
| this.#platform.formatDecimal(defaultValueTo, to.scale)); | ||
| } | ||
| } | ||
@@ -1028,0 +1037,0 @@ if (from.default && to.default) { |
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
1074846
0.06%22386
0.06%