@everystack/cli 0.4.39 → 0.4.40
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/package.json +1 -1
- package/src/cli/model-render.ts +7 -1
package/package.json
CHANGED
package/src/cli/model-render.ts
CHANGED
|
@@ -226,7 +226,13 @@ function renderDefault(expr: string): string | null {
|
|
|
226
226
|
const str = n.match(/^'([\s\S]*)'$/);
|
|
227
227
|
if (str) return `.default(${JSON.stringify(str[1].replace(/''/g, "'"))})`;
|
|
228
228
|
if (n === 'true' || n === 'false') return `.default(${n})`;
|
|
229
|
-
|
|
229
|
+
// A numeric default only survives as a JS number when the number renders back to the
|
|
230
|
+
// SAME text. `0.0` is the number 0, so `.default(0.0)` stores 0 and compiles to
|
|
231
|
+
// `DEFAULT 0` against a live `DEFAULT 0.0` — drift on every apply, forever (21 statements
|
|
232
|
+
// on the first real schema this was measured against). Same for `1.50`, `0.10`, `1e3`.
|
|
233
|
+
// Where the text cannot round-trip, fall through to `.defaultSql()`, which carries the
|
|
234
|
+
// live spelling verbatim. The exact-integer and exact-decimal cases are unchanged.
|
|
235
|
+
if (/^-?\d+(\.\d+)?$/.test(n)) return String(Number(n)) === n ? `.default(${n})` : null;
|
|
230
236
|
return null;
|
|
231
237
|
}
|
|
232
238
|
|