@lark-apaas/db-schema-sync 0.1.12 → 0.1.13-alpha.0

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/dist/bin.js CHANGED
@@ -6,7 +6,7 @@ import {
6
6
  __toESM,
7
7
  generateSchema,
8
8
  resolveEnvOptions
9
- } from "./chunk-SLPV5WXI.js";
9
+ } from "./chunk-IHCFEUCL.js";
10
10
 
11
11
  // node_modules/dotenv/package.json
12
12
  var require_package = __commonJS({
@@ -1629,6 +1629,19 @@ var ImportCollector = class {
1629
1629
  // src/generator/default-value.ts
1630
1630
  var CUSTOM_CAST_TYPES = /* @__PURE__ */ new Set(["user_profile", "file_attachment"]);
1631
1631
  var STRING_NUMERIC_TYPES = /* @__PURE__ */ new Set(["numeric", "decimal"]);
1632
+ var BOOLEAN_TYPES = /* @__PURE__ */ new Set(["bool", "boolean"]);
1633
+ var NUMERIC_LITERAL_TYPES = /* @__PURE__ */ new Set([
1634
+ "int2",
1635
+ "int4",
1636
+ "integer",
1637
+ "int8",
1638
+ "bigint",
1639
+ "float4",
1640
+ "real",
1641
+ "float8",
1642
+ "double precision",
1643
+ "serial"
1644
+ ]);
1632
1645
  var CURRENT_USER_SENTINEL = "current_user";
1633
1646
  function formatDefaultValue(value, field) {
1634
1647
  if (value == null || value === "") return "";
@@ -1636,13 +1649,17 @@ function formatDefaultValue(value, field) {
1636
1649
  if (!trimmed || trimmed.toUpperCase() === "NULL") return "";
1637
1650
  if (/^gen_random_uuid\(\)$/i.test(trimmed)) return ".defaultRandom()";
1638
1651
  if (/^CURRENT_TIMESTAMP$/i.test(trimmed)) return ".default(sql`CURRENT_TIMESTAMP`)";
1639
- if (trimmed === "true") return ".default(true)";
1640
- if (trimmed === "false") return ".default(false)";
1641
- if (/^-?\d+(\.\d+)?$/.test(trimmed)) {
1642
- if (field && STRING_NUMERIC_TYPES.has(field.type)) {
1652
+ if (trimmed === "true" || trimmed === "false") {
1653
+ if (!field || BOOLEAN_TYPES.has(field.type)) {
1654
+ return `.default(${trimmed})`;
1655
+ }
1656
+ } else if (/^-?\d+(\.\d+)?$/.test(trimmed)) {
1657
+ if (!field || NUMERIC_LITERAL_TYPES.has(field.type)) {
1658
+ return `.default(${trimmed})`;
1659
+ }
1660
+ if (STRING_NUMERIC_TYPES.has(field.type)) {
1643
1661
  return `.default('${trimmed}')`;
1644
1662
  }
1645
- return `.default(${trimmed})`;
1646
1663
  }
1647
1664
  if (field && STRING_NUMERIC_TYPES.has(field.type)) {
1648
1665
  const castMatch = trimmed.match(/^'?(-?\d+(?:\.\d+)?)'?::(?:numeric|decimal)(?:\(\d+(?:,\s*\d+)?\))?$/i);
package/dist/index.js CHANGED
@@ -5,7 +5,7 @@ import {
5
5
  generateSchemaFromData,
6
6
  normalizeApiResponse,
7
7
  resolveEnvOptions
8
- } from "./chunk-SLPV5WXI.js";
8
+ } from "./chunk-IHCFEUCL.js";
9
9
  export {
10
10
  generateSchema,
11
11
  generateSchemaCode,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lark-apaas/db-schema-sync",
3
- "version": "0.1.12",
3
+ "version": "0.1.13-alpha.0",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",