fdb2 1.0.36 → 1.0.37

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.
Files changed (31) hide show
  1. package/dist/public/explorer.css +150 -141
  2. package/dist/public/explorer.js +470 -303
  3. package/dist/public/index.css +85 -7
  4. package/dist/public/index.js +6 -0
  5. package/dist/public/layout.js +1 -1
  6. package/dist/server/service/database/mssql.service.d.ts.map +1 -1
  7. package/dist/server/service/database/mssql.service.js +14 -45
  8. package/dist/server/service/database/mssql.service.js.map +1 -1
  9. package/dist/server/service/database/mssql.service.ts +21 -49
  10. package/dist/server/service/database/mysql.service.d.ts.map +1 -1
  11. package/dist/server/service/database/mysql.service.js +34 -52
  12. package/dist/server/service/database/mysql.service.js.map +1 -1
  13. package/dist/server/service/database/mysql.service.ts +50 -55
  14. package/dist/server/service/database/oracle.service.d.ts.map +1 -1
  15. package/dist/server/service/database/oracle.service.js +16 -53
  16. package/dist/server/service/database/oracle.service.js.map +1 -1
  17. package/dist/server/service/database/oracle.service.ts +23 -56
  18. package/dist/server/service/database/postgres.service.d.ts.map +1 -1
  19. package/dist/server/service/database/postgres.service.js +15 -53
  20. package/dist/server/service/database/postgres.service.js.map +1 -1
  21. package/dist/server/service/database/postgres.service.ts +22 -57
  22. package/dist/server/service/database/sql-type.helper.d.ts +28 -0
  23. package/dist/server/service/database/sql-type.helper.d.ts.map +1 -0
  24. package/dist/server/service/database/sql-type.helper.js +151 -0
  25. package/dist/server/service/database/sql-type.helper.js.map +1 -0
  26. package/dist/server/service/database/sql-type.helper.ts +157 -0
  27. package/dist/server/service/database/sqlite.service.d.ts.map +1 -1
  28. package/dist/server/service/database/sqlite.service.js +58 -67
  29. package/dist/server/service/database/sqlite.service.js.map +1 -1
  30. package/dist/server/service/database/sqlite.service.ts +72 -72
  31. package/package.json +1 -1
@@ -414,7 +414,7 @@ var init_database = __esmMin((() => {
414
414
  }));
415
415
  //#endregion
416
416
  //#region src/components/connection-editor/index.vue?vue&type=script&setup=true&lang.ts
417
- var _hoisted_1$9, _hoisted_2$9, _hoisted_3$9, _hoisted_4$9, _hoisted_5$9, _hoisted_6$9, _hoisted_7$9, _hoisted_8$9, _hoisted_9$9, _hoisted_10$9, _hoisted_11$9, _hoisted_12$9, _hoisted_13$9, _hoisted_14$9, _hoisted_15$9, _hoisted_16$9, _hoisted_17$9, _hoisted_18$9, _hoisted_19$9, _hoisted_20$8, _hoisted_21$8, _hoisted_22$8, _hoisted_23$8, _hoisted_24$8, _hoisted_25$8, _hoisted_26$7, _hoisted_27$7, _hoisted_28$7, _hoisted_29$7, _hoisted_30$6, _hoisted_31$6, _hoisted_32$6, _hoisted_33$6, _hoisted_34$6, _hoisted_35$6, _hoisted_36$6, _hoisted_37$6, _hoisted_38$6, _hoisted_39$6, _hoisted_40$6, _hoisted_41$6, _hoisted_42$6, _hoisted_43$6, _hoisted_44$6, _hoisted_45$6, _hoisted_46$6, _hoisted_47$6, _hoisted_48$5, _hoisted_49$5, _hoisted_50$5, _hoisted_51$5, _hoisted_52$4, _hoisted_53$4, _hoisted_54$4, _hoisted_55$4, _hoisted_56$4, _hoisted_57$4, _hoisted_58$4, _hoisted_59$4, _hoisted_60$4, _hoisted_61$4, index_vue_vue_type_script_setup_true_lang_default;
417
+ var _hoisted_1$9, _hoisted_2$9, _hoisted_3$9, _hoisted_4$9, _hoisted_5$9, _hoisted_6$9, _hoisted_7$9, _hoisted_8$9, _hoisted_9$9, _hoisted_10$9, _hoisted_11$9, _hoisted_12$9, _hoisted_13$9, _hoisted_14$9, _hoisted_15$9, _hoisted_16$9, _hoisted_17$9, _hoisted_18$9, _hoisted_19$9, _hoisted_20$8, _hoisted_21$8, _hoisted_22$8, _hoisted_23$8, _hoisted_24$8, _hoisted_25$8, _hoisted_26$7, _hoisted_27$7, _hoisted_28$7, _hoisted_29$7, _hoisted_30$6, _hoisted_31$6, _hoisted_32$6, _hoisted_33$6, _hoisted_34$6, _hoisted_35$6, _hoisted_36$6, _hoisted_37$6, _hoisted_38$6, _hoisted_39$6, _hoisted_40$6, _hoisted_41$6, _hoisted_42$6, _hoisted_43$6, _hoisted_44$6, _hoisted_45$6, _hoisted_46$6, _hoisted_47$6, _hoisted_48$5, _hoisted_49$5, _hoisted_50$5, _hoisted_51$5, _hoisted_52$5, _hoisted_53$5, _hoisted_54$4, _hoisted_55$4, _hoisted_56$4, _hoisted_57$4, _hoisted_58$4, _hoisted_59$4, _hoisted_60$4, _hoisted_61$4, index_vue_vue_type_script_setup_true_lang_default;
418
418
  var init_index_vue_vue_type_script_setup_true_lang = __esmMin((() => {
419
419
  init_vue_runtime_esm_bundler();
420
420
  init_vue_i18n();
@@ -478,8 +478,8 @@ var init_index_vue_vue_type_script_setup_true_lang = __esmMin((() => {
478
478
  _hoisted_49$5 = { class: "form-section" };
479
479
  _hoisted_50$5 = { class: "section-header" };
480
480
  _hoisted_51$5 = { class: "section-title" };
481
- _hoisted_52$4 = { class: "section-content" };
482
- _hoisted_53$4 = { class: "form-group-modern" };
481
+ _hoisted_52$5 = { class: "section-content" };
482
+ _hoisted_53$5 = { class: "form-group-modern" };
483
483
  _hoisted_54$4 = { class: "form-label-modern" };
484
484
  _hoisted_55$4 = { class: "form-check-modern" };
485
485
  _hoisted_56$4 = {
@@ -825,7 +825,7 @@ var init_index_vue_vue_type_script_setup_true_lang = __esmMin((() => {
825
825
  "onUpdate:modelValue": _cache[8] || (_cache[8] = ($event) => connectionForm.value.password = $event),
826
826
  placeholder: _ctx.$t("connection.passwordPlaceholder")
827
827
  }, null, 8, _hoisted_48$5), [[vModelText, connectionForm.value.password]])])])])]),
828
- createBaseVNode("div", _hoisted_49$5, [createBaseVNode("div", _hoisted_50$5, [_cache[30] || (_cache[30] = createBaseVNode("div", { class: "section-icon" }, [createBaseVNode("i", { class: "bi bi-gear" })], -1)), createBaseVNode("h3", _hoisted_51$5, toDisplayString(_ctx.$t("connection.otherOptions")), 1)]), createBaseVNode("div", _hoisted_52$4, [createBaseVNode("div", _hoisted_53$4, [createBaseVNode("label", _hoisted_54$4, [_cache[31] || (_cache[31] = createBaseVNode("i", { class: "bi bi-toggle-on me-2" }, null, -1)), createTextVNode(toDisplayString(_ctx.$t("connection.connectionStatus")), 1)]), createBaseVNode("div", _hoisted_55$4, [withDirectives(createBaseVNode("input", {
828
+ createBaseVNode("div", _hoisted_49$5, [createBaseVNode("div", _hoisted_50$5, [_cache[30] || (_cache[30] = createBaseVNode("div", { class: "section-icon" }, [createBaseVNode("i", { class: "bi bi-gear" })], -1)), createBaseVNode("h3", _hoisted_51$5, toDisplayString(_ctx.$t("connection.otherOptions")), 1)]), createBaseVNode("div", _hoisted_52$5, [createBaseVNode("div", _hoisted_53$5, [createBaseVNode("label", _hoisted_54$4, [_cache[31] || (_cache[31] = createBaseVNode("i", { class: "bi bi-toggle-on me-2" }, null, -1)), createTextVNode(toDisplayString(_ctx.$t("connection.connectionStatus")), 1)]), createBaseVNode("div", _hoisted_55$4, [withDirectives(createBaseVNode("input", {
829
829
  class: "form-check-input-modern",
830
830
  type: "checkbox",
831
831
  "onUpdate:modelValue": _cache[9] || (_cache[9] = ($event) => connectionForm.value.enabled = $event),
@@ -53513,7 +53513,7 @@ var init_sql_executor = __esmMin((() => {
53513
53513
  }));
53514
53514
  //#endregion
53515
53515
  //#region src/platform/database/components/connection-detail.vue?vue&type=script&setup=true&lang.ts
53516
- var _hoisted_1$7, _hoisted_2$7, _hoisted_3$7, _hoisted_4$7, _hoisted_5$7, _hoisted_6$7, _hoisted_7$7, _hoisted_8$7, _hoisted_9$7, _hoisted_10$7, _hoisted_11$7, _hoisted_12$7, _hoisted_13$7, _hoisted_14$7, _hoisted_15$7, _hoisted_16$7, _hoisted_17$7, _hoisted_18$7, _hoisted_19$7, _hoisted_20$7, _hoisted_21$7, _hoisted_22$7, _hoisted_23$7, _hoisted_24$7, _hoisted_25$7, _hoisted_26$6, _hoisted_27$6, _hoisted_28$6, _hoisted_29$6, _hoisted_30$5, _hoisted_31$5, _hoisted_32$5, _hoisted_33$5, _hoisted_34$5, _hoisted_35$5, _hoisted_36$5, _hoisted_37$5, _hoisted_38$5, _hoisted_39$5, _hoisted_40$5, _hoisted_41$5, _hoisted_42$5, _hoisted_43$5, _hoisted_44$5, _hoisted_45$5, _hoisted_46$5, _hoisted_47$5, _hoisted_48$4, _hoisted_49$4, _hoisted_50$4, _hoisted_51$4, _hoisted_52$3, _hoisted_53$3, _hoisted_54$3, _hoisted_55$3, _hoisted_56$3, _hoisted_57$3, _hoisted_58$3, _hoisted_59$3, _hoisted_60$3, _hoisted_61$3, _hoisted_62$3, _hoisted_63$3, _hoisted_64$3, _hoisted_65$3, _hoisted_66$3, _hoisted_67$3, _hoisted_68$3, _hoisted_69$3, _hoisted_70$3, _hoisted_71$3, _hoisted_72$3, _hoisted_73$3, _hoisted_74$2, _hoisted_75$2, _hoisted_76$2, _hoisted_77$2, _hoisted_78$2, _hoisted_79$2, _hoisted_80$2, _hoisted_81$2, _hoisted_82$2, _hoisted_83$2, _hoisted_84$2, _hoisted_85$2, _hoisted_86$2, _hoisted_87$2, _hoisted_88$2, _hoisted_89$2, _hoisted_90$2, _hoisted_91$2, _hoisted_92$2, _hoisted_93$2, _hoisted_94$2, _hoisted_95$2, _hoisted_96$2, _hoisted_97$2, _hoisted_98$2, _hoisted_99$2, _hoisted_100$2, _hoisted_101$2, _hoisted_102$2, _hoisted_103$2, _hoisted_104$2, _hoisted_105$2, _hoisted_106$2, _hoisted_107$2, _hoisted_108$2, _hoisted_109$1, _hoisted_110$1, _hoisted_111$1, _hoisted_112$1, connection_detail_vue_vue_type_script_setup_true_lang_default;
53516
+ var _hoisted_1$7, _hoisted_2$7, _hoisted_3$7, _hoisted_4$7, _hoisted_5$7, _hoisted_6$7, _hoisted_7$7, _hoisted_8$7, _hoisted_9$7, _hoisted_10$7, _hoisted_11$7, _hoisted_12$7, _hoisted_13$7, _hoisted_14$7, _hoisted_15$7, _hoisted_16$7, _hoisted_17$7, _hoisted_18$7, _hoisted_19$7, _hoisted_20$7, _hoisted_21$7, _hoisted_22$7, _hoisted_23$7, _hoisted_24$7, _hoisted_25$7, _hoisted_26$6, _hoisted_27$6, _hoisted_28$6, _hoisted_29$6, _hoisted_30$5, _hoisted_31$5, _hoisted_32$5, _hoisted_33$5, _hoisted_34$5, _hoisted_35$5, _hoisted_36$5, _hoisted_37$5, _hoisted_38$5, _hoisted_39$5, _hoisted_40$5, _hoisted_41$5, _hoisted_42$5, _hoisted_43$5, _hoisted_44$5, _hoisted_45$5, _hoisted_46$5, _hoisted_47$5, _hoisted_48$4, _hoisted_49$4, _hoisted_50$4, _hoisted_51$4, _hoisted_52$4, _hoisted_53$4, _hoisted_54$3, _hoisted_55$3, _hoisted_56$3, _hoisted_57$3, _hoisted_58$3, _hoisted_59$3, _hoisted_60$3, _hoisted_61$3, _hoisted_62$3, _hoisted_63$3, _hoisted_64$3, _hoisted_65$3, _hoisted_66$3, _hoisted_67$3, _hoisted_68$3, _hoisted_69$3, _hoisted_70$3, _hoisted_71$3, _hoisted_72$3, _hoisted_73$3, _hoisted_74$2, _hoisted_75$2, _hoisted_76$2, _hoisted_77$2, _hoisted_78$2, _hoisted_79$2, _hoisted_80$2, _hoisted_81$2, _hoisted_82$2, _hoisted_83$2, _hoisted_84$2, _hoisted_85$2, _hoisted_86$2, _hoisted_87$2, _hoisted_88$2, _hoisted_89$2, _hoisted_90$2, _hoisted_91$2, _hoisted_92$2, _hoisted_93$2, _hoisted_94$2, _hoisted_95$2, _hoisted_96$2, _hoisted_97$2, _hoisted_98$2, _hoisted_99$2, _hoisted_100$2, _hoisted_101$2, _hoisted_102$2, _hoisted_103$2, _hoisted_104$2, _hoisted_105$2, _hoisted_106$2, _hoisted_107$2, _hoisted_108$2, _hoisted_109$1, _hoisted_110$1, _hoisted_111$1, _hoisted_112$1, connection_detail_vue_vue_type_script_setup_true_lang_default;
53517
53517
  var init_connection_detail_vue_vue_type_script_setup_true_lang = __esmMin((() => {
53518
53518
  init_vue_runtime_esm_bundler();
53519
53519
  init_vue_router();
@@ -53575,8 +53575,8 @@ var init_connection_detail_vue_vue_type_script_setup_true_lang = __esmMin((() =>
53575
53575
  _hoisted_49$4 = { class: "action-text" };
53576
53576
  _hoisted_50$4 = { class: "action-text" };
53577
53577
  _hoisted_51$4 = { class: "action-text" };
53578
- _hoisted_52$3 = { class: "connection-tabs" };
53579
- _hoisted_53$3 = { class: "nav nav-tabs" };
53578
+ _hoisted_52$4 = { class: "connection-tabs" };
53579
+ _hoisted_53$4 = { class: "nav nav-tabs" };
53580
53580
  _hoisted_54$3 = { class: "nav-item" };
53581
53581
  _hoisted_55$3 = { class: "badge bg-primary ms-1" };
53582
53582
  _hoisted_56$3 = { class: "nav-item" };
@@ -53894,7 +53894,7 @@ var init_connection_detail_vue_vue_type_script_setup_true_lang = __esmMin((() =>
53894
53894
  onClick: viewLogs
53895
53895
  }, [_cache[22] || (_cache[22] = createBaseVNode("div", { class: "action-icon" }, [createBaseVNode("i", { class: "bi bi-file-text" })], -1)), createBaseVNode("div", _hoisted_51$4, toDisplayString(_ctx.$t("connection.viewLogs")), 1)])
53896
53896
  ])]),
53897
- createBaseVNode("div", _hoisted_52$3, [createBaseVNode("ul", _hoisted_53$3, [createBaseVNode("li", _hoisted_54$3, [createBaseVNode("button", {
53897
+ createBaseVNode("div", _hoisted_52$4, [createBaseVNode("ul", _hoisted_53$4, [createBaseVNode("li", _hoisted_54$3, [createBaseVNode("button", {
53898
53898
  class: normalizeClass(["nav-link", { active: activeTab.value === "databases" }]),
53899
53899
  onClick: _cache[0] || (_cache[0] = ($event) => activeTab.value = "databases")
53900
53900
  }, [
@@ -55031,7 +55031,7 @@ var init_database_types$1 = __esmMin((() => {
55031
55031
  label: "VARCHAR",
55032
55032
  category: "string",
55033
55033
  requiresLength: true,
55034
- defaultLength: 1,
55034
+ defaultLength: 255,
55035
55035
  description: "可变长度字符串"
55036
55036
  },
55037
55037
  {
@@ -55053,7 +55053,7 @@ var init_database_types$1 = __esmMin((() => {
55053
55053
  label: "NVARCHAR",
55054
55054
  category: "string",
55055
55055
  requiresLength: true,
55056
- defaultLength: 1,
55056
+ defaultLength: 255,
55057
55057
  description: "Unicode可变长度字符串"
55058
55058
  },
55059
55059
  {
@@ -55075,7 +55075,7 @@ var init_database_types$1 = __esmMin((() => {
55075
55075
  label: "VARBINARY",
55076
55076
  category: "binary",
55077
55077
  requiresLength: true,
55078
- defaultLength: 1,
55078
+ defaultLength: 255,
55079
55079
  description: "可变长度二进制"
55080
55080
  },
55081
55081
  {
@@ -55265,7 +55265,7 @@ var init_database_types = __esmMin((() => {
55265
55265
  }));
55266
55266
  //#endregion
55267
55267
  //#region src/platform/database/components/table-editor.vue?vue&type=script&setup=true&lang.ts
55268
- var _hoisted_1$6, _hoisted_2$6, _hoisted_3$6, _hoisted_4$6, _hoisted_5$6, _hoisted_6$6, _hoisted_7$6, _hoisted_8$6, _hoisted_9$6, _hoisted_10$6, _hoisted_11$6, _hoisted_12$6, _hoisted_13$6, _hoisted_14$6, _hoisted_15$6, _hoisted_16$6, _hoisted_17$6, _hoisted_18$6, _hoisted_19$6, _hoisted_20$6, _hoisted_21$6, _hoisted_22$6, _hoisted_23$6, _hoisted_24$6, _hoisted_25$6, _hoisted_26$5, _hoisted_27$5, _hoisted_28$5, _hoisted_29$5, _hoisted_30$4, _hoisted_31$4, _hoisted_32$4, _hoisted_33$4, _hoisted_34$4, _hoisted_35$4, _hoisted_36$4, _hoisted_37$4, _hoisted_38$4, _hoisted_39$4, _hoisted_40$4, _hoisted_41$4, _hoisted_42$4, _hoisted_43$4, _hoisted_44$4, _hoisted_45$4, _hoisted_46$4, _hoisted_47$4, _hoisted_48$3, _hoisted_49$3, _hoisted_50$3, _hoisted_51$3, table_editor_vue_vue_type_script_setup_true_lang_default;
55268
+ var _hoisted_1$6, _hoisted_2$6, _hoisted_3$6, _hoisted_4$6, _hoisted_5$6, _hoisted_6$6, _hoisted_7$6, _hoisted_8$6, _hoisted_9$6, _hoisted_10$6, _hoisted_11$6, _hoisted_12$6, _hoisted_13$6, _hoisted_14$6, _hoisted_15$6, _hoisted_16$6, _hoisted_17$6, _hoisted_18$6, _hoisted_19$6, _hoisted_20$6, _hoisted_21$6, _hoisted_22$6, _hoisted_23$6, _hoisted_24$6, _hoisted_25$6, _hoisted_26$5, _hoisted_27$5, _hoisted_28$5, _hoisted_29$5, _hoisted_30$4, _hoisted_31$4, _hoisted_32$4, _hoisted_33$4, _hoisted_34$4, _hoisted_35$4, _hoisted_36$4, _hoisted_37$4, _hoisted_38$4, _hoisted_39$4, _hoisted_40$4, _hoisted_41$4, _hoisted_42$4, _hoisted_43$4, _hoisted_44$4, _hoisted_45$4, _hoisted_46$4, _hoisted_47$4, _hoisted_48$3, _hoisted_49$3, _hoisted_50$3, _hoisted_51$3, _hoisted_52$3, _hoisted_53$3, CUSTOM_TYPE_VALUE, table_editor_vue_vue_type_script_setup_true_lang_default;
55269
55269
  var init_table_editor_vue_vue_type_script_setup_true_lang = __esmMin((() => {
55270
55270
  init_vue_runtime_esm_bundler();
55271
55271
  init_vue_i18n();
@@ -55273,63 +55273,73 @@ var init_table_editor_vue_vue_type_script_setup_true_lang = __esmMin((() => {
55273
55273
  init_modal();
55274
55274
  init_database_types$1();
55275
55275
  init_database_types();
55276
- _hoisted_1$6 = { class: "modal-content" };
55277
- _hoisted_2$6 = { class: "modal-header" };
55278
- _hoisted_3$6 = { class: "modal-title" };
55279
- _hoisted_4$6 = { class: "modal-body" };
55280
- _hoisted_5$6 = { class: "table-info-section mb-4" };
55281
- _hoisted_6$6 = { class: "section-title" };
55282
- _hoisted_7$6 = { class: "row" };
55283
- _hoisted_8$6 = { class: "col-md-6" };
55284
- _hoisted_9$6 = { class: "mb-3" };
55285
- _hoisted_10$6 = { class: "form-label" };
55286
- _hoisted_11$6 = ["disabled", "placeholder"];
55287
- _hoisted_12$6 = { class: "col-md-6" };
55288
- _hoisted_13$6 = { class: "mb-3" };
55289
- _hoisted_14$6 = { class: "form-label" };
55290
- _hoisted_15$6 = ["placeholder"];
55291
- _hoisted_16$6 = { class: "columns-section" };
55292
- _hoisted_17$6 = { class: "section-header d-flex justify-content-between align-items-center mb-3" };
55293
- _hoisted_18$6 = { class: "section-title mb-0" };
55294
- _hoisted_19$6 = { class: "table-responsive" };
55295
- _hoisted_20$6 = { class: "table table-sm table-bordered" };
55296
- _hoisted_21$6 = { width: "120" };
55297
- _hoisted_22$6 = { width: "140" };
55298
- _hoisted_23$6 = { width: "120" };
55299
- _hoisted_24$6 = { width: "80" };
55300
- _hoisted_25$6 = { width: "100" };
55301
- _hoisted_26$5 = { width: "80" };
55276
+ _hoisted_1$6 = {
55277
+ key: 0,
55278
+ class: "modal fade show",
55279
+ style: {
55280
+ "display": "block",
55281
+ "background-color": "rgba(0,0,0,0.5)"
55282
+ }
55283
+ };
55284
+ _hoisted_2$6 = { class: "modal-content" };
55285
+ _hoisted_3$6 = { class: "modal-header" };
55286
+ _hoisted_4$6 = { class: "modal-title" };
55287
+ _hoisted_5$6 = { class: "modal-body" };
55288
+ _hoisted_6$6 = { class: "table-info-section mb-4" };
55289
+ _hoisted_7$6 = { class: "section-title" };
55290
+ _hoisted_8$6 = { class: "row" };
55291
+ _hoisted_9$6 = { class: "col-md-6" };
55292
+ _hoisted_10$6 = { class: "mb-3" };
55293
+ _hoisted_11$6 = { class: "form-label" };
55294
+ _hoisted_12$6 = ["disabled", "placeholder"];
55295
+ _hoisted_13$6 = { class: "col-md-6" };
55296
+ _hoisted_14$6 = { class: "mb-3" };
55297
+ _hoisted_15$6 = { class: "form-label" };
55298
+ _hoisted_16$6 = ["placeholder"];
55299
+ _hoisted_17$6 = { class: "columns-section" };
55300
+ _hoisted_18$6 = { class: "section-header d-flex justify-content-between align-items-center mb-3" };
55301
+ _hoisted_19$6 = { class: "section-title mb-0" };
55302
+ _hoisted_20$6 = { class: "table-responsive" };
55303
+ _hoisted_21$6 = { class: "table table-sm table-bordered" };
55304
+ _hoisted_22$6 = { width: "120" };
55305
+ _hoisted_23$6 = { width: "140" };
55306
+ _hoisted_24$6 = { width: "120" };
55307
+ _hoisted_25$6 = { width: "80" };
55308
+ _hoisted_26$5 = { width: "100" };
55302
55309
  _hoisted_27$5 = { width: "80" };
55303
- _hoisted_28$5 = { width: "100" };
55304
- _hoisted_29$5 = ["onUpdate:modelValue", "placeholder"];
55305
- _hoisted_30$4 = ["onUpdate:modelValue"];
55306
- _hoisted_31$4 = { value: "" };
55307
- _hoisted_32$4 = ["label"];
55308
- _hoisted_33$4 = ["value"];
55309
- _hoisted_34$4 = {
55310
+ _hoisted_28$5 = { width: "80" };
55311
+ _hoisted_29$5 = { width: "100" };
55312
+ _hoisted_30$4 = ["onUpdate:modelValue", "placeholder"];
55313
+ _hoisted_31$4 = ["onUpdate:modelValue"];
55314
+ _hoisted_32$4 = { value: "" };
55315
+ _hoisted_33$4 = ["label"];
55316
+ _hoisted_34$4 = ["value"];
55317
+ _hoisted_35$4 = ["onUpdate:modelValue", "placeholder"];
55318
+ _hoisted_36$4 = {
55310
55319
  key: 0,
55311
55320
  class: "input-group input-group-sm"
55312
55321
  };
55313
- _hoisted_35$4 = ["onUpdate:modelValue", "placeholder"];
55314
- _hoisted_36$4 = ["onUpdate:modelValue", "placeholder"];
55315
55322
  _hoisted_37$4 = ["onUpdate:modelValue", "placeholder"];
55316
- _hoisted_38$4 = {
55323
+ _hoisted_38$4 = ["onUpdate:modelValue", "placeholder"];
55324
+ _hoisted_39$4 = ["onUpdate:modelValue", "placeholder"];
55325
+ _hoisted_40$4 = {
55317
55326
  key: 1,
55318
55327
  class: "text-muted"
55319
55328
  };
55320
- _hoisted_39$4 = { class: "form-check" };
55321
- _hoisted_40$4 = ["onUpdate:modelValue"];
55322
- _hoisted_41$4 = ["onUpdate:modelValue", "placeholder"];
55323
- _hoisted_42$4 = { class: "form-check" };
55324
- _hoisted_43$4 = ["onUpdate:modelValue", "onChange"];
55329
+ _hoisted_41$4 = { class: "form-check" };
55330
+ _hoisted_42$4 = ["onUpdate:modelValue"];
55331
+ _hoisted_43$4 = ["onUpdate:modelValue", "placeholder"];
55325
55332
  _hoisted_44$4 = { class: "form-check" };
55326
- _hoisted_45$4 = ["onUpdate:modelValue", "disabled"];
55327
- _hoisted_46$4 = ["onUpdate:modelValue", "placeholder"];
55328
- _hoisted_47$4 = ["onClick", "disabled"];
55329
- _hoisted_48$3 = { class: "sql-preview-section mt-4" };
55330
- _hoisted_49$3 = { class: "section-title" };
55331
- _hoisted_50$3 = { class: "sql-preview bg-light p-3 rounded" };
55332
- _hoisted_51$3 = { class: "modal-footer" };
55333
+ _hoisted_45$4 = ["onUpdate:modelValue", "onChange"];
55334
+ _hoisted_46$4 = { class: "form-check" };
55335
+ _hoisted_47$4 = ["onUpdate:modelValue", "disabled"];
55336
+ _hoisted_48$3 = ["onUpdate:modelValue", "placeholder"];
55337
+ _hoisted_49$3 = ["onClick", "disabled"];
55338
+ _hoisted_50$3 = { class: "sql-preview-section mt-4" };
55339
+ _hoisted_51$3 = { class: "section-title" };
55340
+ _hoisted_52$3 = { class: "sql-preview" };
55341
+ _hoisted_53$3 = { class: "modal-footer" };
55342
+ CUSTOM_TYPE_VALUE = "__custom__";
55333
55343
  table_editor_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineComponent({
55334
55344
  __name: "table-editor",
55335
55345
  props: {
@@ -55346,6 +55356,35 @@ var init_table_editor_vue_vue_type_script_setup_true_lang = __esmMin((() => {
55346
55356
  const emit = __emit;
55347
55357
  const databaseService = new DatabaseService();
55348
55358
  const { t } = useI18n();
55359
+ const dbType = computed(() => (props.connection?.type || "").toLowerCase());
55360
+ const MYSQL_LIKE_TYPES = /* @__PURE__ */ new Set([
55361
+ "mysql",
55362
+ "mariadb",
55363
+ "aurora-mysql",
55364
+ "auroramysql"
55365
+ ]);
55366
+ const POSTGRES_LIKE_TYPES = /* @__PURE__ */ new Set([
55367
+ "postgres",
55368
+ "postgresql",
55369
+ "cockroachdb",
55370
+ "aurora-postgres",
55371
+ "aurorapostgres",
55372
+ "aurora-postgresql"
55373
+ ]);
55374
+ const isMySqlLike = () => MYSQL_LIKE_TYPES.has(dbType.value);
55375
+ const isPostgresLike = () => POSTGRES_LIKE_TYPES.has(dbType.value);
55376
+ function rawType(column) {
55377
+ if (!column) return "";
55378
+ return column.type === CUSTOM_TYPE_VALUE ? column.customType || "" : column.type || "";
55379
+ }
55380
+ function sqlType(column) {
55381
+ const type = rawType(column);
55382
+ if (dbType.value === "sqlite" && column?.isAutoIncrement && /^INT$/i.test(type.trim())) return "INTEGER";
55383
+ return type;
55384
+ }
55385
+ function escapeSqlString(value) {
55386
+ return String(value ?? "").replace(/'/g, "''");
55387
+ }
55349
55388
  const columnTypes = computed(() => {
55350
55389
  if (!props.connection) return [];
55351
55390
  return getColumnTypesByName(props.connection.type);
@@ -55364,6 +55403,7 @@ var init_table_editor_vue_vue_type_script_setup_true_lang = __esmMin((() => {
55364
55403
  columns: [{
55365
55404
  name: "",
55366
55405
  type: "",
55406
+ customType: "",
55367
55407
  length: "",
55368
55408
  precision: null,
55369
55409
  scale: null,
@@ -55400,10 +55440,13 @@ var init_table_editor_vue_vue_type_script_setup_true_lang = __esmMin((() => {
55400
55440
  tableName: props.table.name || "",
55401
55441
  tableComment: props.table.comment || "",
55402
55442
  columns: columns.map((col) => {
55403
- const parsed = parseColumnType(col.type || "");
55443
+ const rawColType = col.type || "";
55444
+ const parsed = parseColumnType(rawColType);
55445
+ const isNonNumericParamType = /^[a-zA-Z\s]+\([^)]*'[^)]*\)$/.test(rawColType);
55404
55446
  return {
55405
55447
  name: col.name || "",
55406
- type: parsed.baseType,
55448
+ type: isNonNumericParamType ? CUSTOM_TYPE_VALUE : parsed.baseType,
55449
+ customType: isNonNumericParamType ? rawColType : col.customType || "",
55407
55450
  length: col.length || parsed.length || "",
55408
55451
  precision: col.precision || parsed.precision || null,
55409
55452
  scale: col.scale || parsed.scale || null,
@@ -55418,12 +55461,14 @@ var init_table_editor_vue_vue_type_script_setup_true_lang = __esmMin((() => {
55418
55461
  formData.value = { ...tableData };
55419
55462
  originalTableData.value = JSON.parse(JSON.stringify(tableData));
55420
55463
  } else {
55464
+ const isCreateWithPrefill = props.mode === "create" && props.table;
55421
55465
  formData.value = {
55422
- tableName: "",
55423
- tableComment: "",
55466
+ tableName: isCreateWithPrefill ? props.table.name || "" : "",
55467
+ tableComment: isCreateWithPrefill ? props.table.comment || "" : "",
55424
55468
  columns: [{
55425
55469
  name: "",
55426
55470
  type: "",
55471
+ customType: "",
55427
55472
  length: "",
55428
55473
  precision: null,
55429
55474
  scale: null,
@@ -55441,14 +55486,79 @@ var init_table_editor_vue_vue_type_script_setup_true_lang = __esmMin((() => {
55441
55486
  };
55442
55487
  }
55443
55488
  }
55489
+ function isColumnDefinitionChanged(newCol, originalCol) {
55490
+ return newCol.type !== originalCol.type || newCol.customType !== originalCol.customType || newCol.length !== originalCol.length || newCol.precision !== originalCol.precision || newCol.scale !== originalCol.scale || newCol.nullable !== originalCol.nullable || newCol.defaultValue !== originalCol.defaultValue || newCol.isPrimary !== originalCol.isPrimary || newCol.isAutoIncrement !== originalCol.isAutoIncrement || newCol.comment !== originalCol.comment;
55491
+ }
55492
+ function levenshtein(a, b) {
55493
+ const m = a.length;
55494
+ const n = b.length;
55495
+ if (m === 0) return n;
55496
+ if (n === 0) return m;
55497
+ let prev = new Array(n + 1).fill(0);
55498
+ let curr = new Array(n + 1).fill(0);
55499
+ for (let j = 0; j <= n; j++) prev[j] = j;
55500
+ for (let i = 1; i <= m; i++) {
55501
+ curr[0] = i;
55502
+ const aChar = a.charAt(i - 1);
55503
+ for (let j = 1; j <= n; j++) {
55504
+ const cost = aChar === b.charAt(j - 1) ? 0 : 1;
55505
+ curr[j] = Math.min(curr[j - 1] + 1, prev[j] + 1, prev[j - 1] + cost);
55506
+ }
55507
+ const tmp = prev;
55508
+ prev = curr;
55509
+ curr = tmp;
55510
+ }
55511
+ return prev[n];
55512
+ }
55513
+ function renameNameScore(oldName, newName) {
55514
+ const a = String(oldName || "").trim().toLowerCase();
55515
+ const b = String(newName || "").trim().toLowerCase();
55516
+ if (!a || !b || a === b) return 0;
55517
+ if (a.startsWith(b) || b.startsWith(a)) return 3;
55518
+ const maxLen = Math.max(a.length, b.length);
55519
+ if (maxLen > 0 && levenshtein(a, b) <= Math.max(1, Math.floor(maxLen / 3))) return 1;
55520
+ return 0;
55521
+ }
55522
+ /**
55523
+ * 重命名检测:把「新增列」与「删除列」中名称相近的配成对。
55524
+ * 否则改名会被生成为 DROP COLUMN + ADD COLUMN,导致原数据丢失。
55525
+ */
55526
+ function matchRenamedColumns(addedColumns, deletedColumns) {
55527
+ const pairs = [];
55528
+ const usedOld = /* @__PURE__ */ new Set();
55529
+ addedColumns.forEach((newCol, newIndex) => {
55530
+ let bestOld = null;
55531
+ let bestScore = 0;
55532
+ deletedColumns.forEach((oldCol, oldIndex) => {
55533
+ if (usedOld.has(oldCol)) return;
55534
+ const score = renameNameScore(oldCol.name, newCol.name);
55535
+ if (score === 0) return;
55536
+ const total = score + (oldIndex === newIndex ? .1 : 0);
55537
+ if (total > bestScore) {
55538
+ bestScore = total;
55539
+ bestOld = oldCol;
55540
+ }
55541
+ });
55542
+ if (bestOld) {
55543
+ usedOld.add(bestOld);
55544
+ pairs.push({
55545
+ oldColumn: bestOld,
55546
+ newColumn: newCol
55547
+ });
55548
+ }
55549
+ });
55550
+ return pairs;
55551
+ }
55444
55552
  function calculateTableDiff() {
55445
55553
  const diff = {
55446
55554
  tableName: formData.value.tableName,
55447
55555
  tableCommentChanged: formData.value.tableComment !== originalTableData.value.tableComment,
55448
55556
  tableComment: formData.value.tableComment,
55557
+ columnOrder: formData.value.columns.map((c) => c.name).filter(Boolean),
55449
55558
  addedColumns: [],
55450
55559
  modifiedColumns: [],
55451
- deletedColumns: []
55560
+ deletedColumns: [],
55561
+ renamedColumns: []
55452
55562
  };
55453
55563
  const originalColumnsMap = /* @__PURE__ */ new Map();
55454
55564
  originalTableData.value.columns.forEach((col) => {
@@ -55457,20 +55567,33 @@ var init_table_editor_vue_vue_type_script_setup_true_lang = __esmMin((() => {
55457
55567
  formData.value.columns.forEach((newCol) => {
55458
55568
  const originalCol = originalColumnsMap.get(newCol.name);
55459
55569
  if (!originalCol) diff.addedColumns.push(newCol);
55460
- else if (newCol.type !== originalCol.type || newCol.length !== originalCol.length || newCol.precision !== originalCol.precision || newCol.scale !== originalCol.scale || newCol.nullable !== originalCol.nullable || newCol.defaultValue !== originalCol.defaultValue || newCol.isPrimary !== originalCol.isPrimary || newCol.isAutoIncrement !== originalCol.isAutoIncrement || newCol.comment !== originalCol.comment) diff.modifiedColumns.push({
55570
+ else if (isColumnDefinitionChanged(newCol, originalCol)) diff.modifiedColumns.push({
55461
55571
  oldColumn: originalCol,
55462
55572
  newColumn: newCol
55463
55573
  });
55464
55574
  });
55465
- originalTableData.value.columns.forEach((originalCol) => {
55466
- if (!formData.value.columns.some((newCol) => newCol.name === originalCol.name)) diff.deletedColumns.push(originalCol);
55467
- });
55575
+ const deletedColumns = originalTableData.value.columns.filter((originalCol) => !formData.value.columns.some((newCol) => newCol.name === originalCol.name));
55576
+ const renamedColumns = matchRenamedColumns(diff.addedColumns, deletedColumns);
55577
+ if (renamedColumns.length > 0) {
55578
+ const renamedNewNames = new Set(renamedColumns.map((r) => r.newColumn));
55579
+ const renamedOldColumns = new Set(renamedColumns.map((r) => r.oldColumn));
55580
+ diff.renamedColumns = renamedColumns;
55581
+ diff.addedColumns = diff.addedColumns.filter((col) => !renamedNewNames.has(col));
55582
+ diff.deletedColumns = deletedColumns.filter((col) => !renamedOldColumns.has(col));
55583
+ renamedColumns.forEach(({ oldColumn, newColumn }) => {
55584
+ if (isColumnDefinitionChanged(newColumn, oldColumn)) diff.modifiedColumns.push({
55585
+ oldColumn,
55586
+ newColumn
55587
+ });
55588
+ });
55589
+ } else diff.deletedColumns = deletedColumns;
55468
55590
  return diff;
55469
55591
  }
55470
55592
  function addColumn() {
55471
55593
  formData.value.columns.push({
55472
55594
  name: "",
55473
55595
  type: "",
55596
+ customType: "",
55474
55597
  length: "",
55475
55598
  precision: null,
55476
55599
  scale: null,
@@ -55492,172 +55615,172 @@ var init_table_editor_vue_vue_type_script_setup_true_lang = __esmMin((() => {
55492
55615
  }
55493
55616
  function generateSQL() {
55494
55617
  if (!formData.value.tableName) return "请输入表名";
55618
+ const quoteIdentifier = getQuoter();
55495
55619
  if (props.mode === "create") {
55496
- const quoteIdentifier = (name) => {
55497
- if (!props.connection) return `"${name}"`;
55498
- switch (props.connection.type.toLowerCase()) {
55499
- case "mysql": return `\`${name}\``;
55500
- case "postgres": return `"${name}"`;
55501
- case "sqlite": return `"${name}"`;
55502
- case "oracle": return `"${name.toUpperCase()}"`;
55503
- case "mssql": return `[${name}]`;
55504
- default: return `"${name}"`;
55505
- }
55506
- };
55507
- const columnsSQL = formData.value.columns.map((col) => {
55508
- if (!col.name || !col.type) return "";
55509
- let sql = `${quoteIdentifier(col.name)} ${col.type}`;
55510
- if (!col.type.includes("(") && col.length && (needsLength(col) || col.type.includes("CHAR"))) sql += `(${col.length})`;
55511
- else if (!col.type.includes("(") && col.precision) if (col.scale) sql += `(${col.precision},${col.scale})`;
55512
- else sql += `(${col.precision})`;
55513
- const isSqliteAutoIncrementPrimary = props.connection?.type.toLowerCase() === "sqlite" && col.isAutoIncrement && col.isPrimary;
55514
- if (!col.nullable && !isSqliteAutoIncrementPrimary) sql += " NOT NULL";
55515
- if (col.defaultValue) sql += ` DEFAULT ${formatDefaultValue(col.defaultValue, col.type)}`;
55516
- if (col.isAutoIncrement) switch (props.connection?.type.toLowerCase()) {
55517
- case "mysql":
55518
- sql += " AUTO_INCREMENT";
55519
- break;
55520
- case "postgres":
55521
- if (col.type.toLowerCase().includes("serial") || col.type.toLowerCase().includes("bigserial")) {} else sql += " GENERATED ALWAYS AS IDENTITY";
55522
- break;
55523
- case "sqlite":
55524
- if (col.type.toUpperCase() === "INT") sql = sql.replace(/\bINT\b/, "INTEGER");
55525
- if (col.isPrimary) sql += " PRIMARY KEY AUTOINCREMENT";
55526
- else sql += " AUTOINCREMENT";
55527
- break;
55528
- case "oracle": break;
55529
- case "mssql":
55530
- sql += " IDENTITY(1,1)";
55531
- break;
55532
- }
55533
- if (col.comment) switch (props.connection?.type.toLowerCase()) {
55534
- case "mysql":
55535
- sql += ` COMMENT '${col.comment}'`;
55536
- break;
55537
- case "postgres": break;
55538
- case "sqlite": break;
55539
- case "oracle":
55540
- sql += ` COMMENT '${col.comment}'`;
55541
- break;
55542
- case "mssql": break;
55543
- }
55544
- return sql;
55545
- }).filter((sql) => sql).join(",\n ");
55546
- const primaryKeys = formData.value.columns.filter((col) => col.isPrimary).map((col) => quoteIdentifier(col.name));
55620
+ const type = dbType.value;
55621
+ const columnsSQL = formData.value.columns.filter((col) => col.name && rawType(col)).map((col) => buildColumnDefinition(col, quoteIdentifier)).join(",\n ");
55622
+ if (!columnsSQL) return "请至少完善一个字段";
55623
+ const primaryKeys = formData.value.columns.filter((col) => col.isPrimary && col.name).map((col) => quoteIdentifier(col.name));
55624
+ const hasSqliteAutoIncrementPrimary = type === "sqlite" && formData.value.columns.some((col) => col.isAutoIncrement && col.isPrimary && col.name);
55547
55625
  let sql = `CREATE TABLE ${quoteIdentifier(formData.value.tableName)} (\n ${columnsSQL}`;
55548
- const hasSqliteAutoIncrementPrimary = props.connection?.type.toLowerCase() === "sqlite" && formData.value.columns.some((col) => col.isAutoIncrement && col.isPrimary);
55549
55626
  if (primaryKeys.length > 0 && !hasSqliteAutoIncrementPrimary) sql += `,\n PRIMARY KEY (${primaryKeys.join(", ")})`;
55550
55627
  sql += "\n)";
55551
- switch (props.connection?.type.toLowerCase()) {
55552
- case "mysql":
55553
- if (formData.value.tableComment) sql += ` COMMENT='${formData.value.tableComment}'`;
55554
- sql += " ENGINE=InnoDB DEFAULT CHARSET=utf8mb4";
55555
- break;
55556
- case "postgres": break;
55557
- case "oracle":
55558
- if (formData.value.tableComment) sql += ` COMMENT '${formData.value.tableComment}'`;
55559
- break;
55560
- case "mssql": break;
55561
- }
55562
- if (props.connection?.type.toLowerCase() === "postgres") {
55563
- const commentStatements = [];
55564
- if (formData.value.tableComment) commentStatements.push(`COMMENT ON TABLE ${quoteIdentifier(formData.value.tableName)} IS '${formData.value.tableComment}'`);
55565
- formData.value.columns.forEach((col) => {
55566
- if (col.comment) commentStatements.push(`COMMENT ON COLUMN ${quoteIdentifier(formData.value.tableName)}.${quoteIdentifier(col.name)} IS '${col.comment}'`);
55567
- });
55568
- if (commentStatements.length > 0) sql += ";\n" + commentStatements.join(";\n");
55628
+ if (isMySqlLike()) {
55629
+ if (formData.value.tableComment) sql += ` COMMENT='${escapeSqlString(formData.value.tableComment)}'`;
55630
+ sql += " ENGINE=InnoDB DEFAULT CHARSET=utf8mb4";
55569
55631
  }
55632
+ const commentStatements = [];
55633
+ if (formData.value.tableComment && (isPostgresLike() || dbType.value === "oracle")) commentStatements.push(`COMMENT ON TABLE ${quoteIdentifier(formData.value.tableName)} IS '${escapeSqlString(formData.value.tableComment)}'`);
55634
+ formData.value.columns.forEach((col) => {
55635
+ if (!col.name || !col.comment) return;
55636
+ if (isPostgresLike() || dbType.value === "oracle") commentStatements.push(`COMMENT ON COLUMN ${quoteIdentifier(formData.value.tableName)}.${quoteIdentifier(col.name)} IS '${escapeSqlString(col.comment)}'`);
55637
+ });
55638
+ if (commentStatements.length > 0) sql += ";\n" + commentStatements.join(";\n");
55570
55639
  return sql;
55571
55640
  } else {
55572
- const quoteIdentifier = (name) => {
55573
- if (!props.connection) return `"${name}"`;
55574
- switch (props.connection.type.toLowerCase()) {
55575
- case "mysql": return `\`${name}\``;
55576
- case "postgres": return `"${name}"`;
55577
- case "sqlite": return `"${name}"`;
55578
- case "oracle": return `"${name.toUpperCase()}"`;
55579
- case "mssql": return `[${name}]`;
55580
- default: return `"${name}"`;
55581
- }
55582
- };
55583
- const sqlStatements = [];
55584
- const tableName = formData.value.tableName;
55585
- if (formData.value.tableComment) switch (props.connection?.type.toLowerCase()) {
55641
+ const diff = calculateTableDiff();
55642
+ const tableName = diff.tableName;
55643
+ const statements = [];
55644
+ if (diff.tableCommentChanged && diff.tableComment) {
55645
+ if (isMySqlLike()) statements.push(`ALTER TABLE ${quoteIdentifier(tableName)} COMMENT='${escapeSqlString(diff.tableComment)}'`);
55646
+ else if (isPostgresLike() || dbType.value === "oracle") statements.push(`COMMENT ON TABLE ${quoteIdentifier(tableName)} IS '${escapeSqlString(diff.tableComment)}'`);
55647
+ else if (dbType.value === "mssql" || dbType.value === "sqlserver") statements.push(`EXEC sp_addextendedproperty @name=N'MS_Description', @value=N'${escapeSqlString(diff.tableComment)}', @level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'${escapeSqlString(tableName)}'`);
55648
+ }
55649
+ diff.renamedColumns.forEach(({ oldColumn, newColumn }) => {
55650
+ if (isMySqlLike()) statements.push(`ALTER TABLE ${quoteIdentifier(tableName)} CHANGE COLUMN ${quoteIdentifier(oldColumn.name)} ${quoteIdentifier(newColumn.name)} ${sqlType(newColumn)}${getTypeParams(newColumn)}${buildColumnAttributes(newColumn)}`);
55651
+ else if (isPostgresLike()) statements.push(`ALTER TABLE ${quoteIdentifier(tableName)} RENAME COLUMN ${quoteIdentifier(oldColumn.name)} TO ${quoteIdentifier(newColumn.name)}`);
55652
+ else if (dbType.value === "oracle") statements.push(`ALTER TABLE ${quoteIdentifier(tableName)} RENAME COLUMN ${quoteIdentifier(oldColumn.name)} TO ${quoteIdentifier(newColumn.name)}`);
55653
+ else if (dbType.value === "mssql" || dbType.value === "sqlserver") statements.push(`EXEC sp_rename N'dbo.${escapeSqlString(tableName)}.${escapeSqlString(oldColumn.name)}', N'${escapeSqlString(newColumn.name)}', N'COLUMN'`);
55654
+ else if (dbType.value === "sqlite") statements.push(`ALTER TABLE ${quoteIdentifier(tableName)} RENAME COLUMN ${quoteIdentifier(oldColumn.name)} TO ${quoteIdentifier(newColumn.name)}`);
55655
+ });
55656
+ diff.addedColumns.forEach((col) => {
55657
+ const def = buildColumnAttributes(col);
55658
+ if (dbType.value === "oracle") statements.push(`ALTER TABLE ${quoteIdentifier(tableName)} ADD (${quoteIdentifier(col.name)} ${sqlType(col)}${getTypeParams(col)}${def})`);
55659
+ else if (dbType.value === "mssql" || dbType.value === "sqlserver") statements.push(`ALTER TABLE ${quoteIdentifier(tableName)} ADD ${quoteIdentifier(col.name)} ${sqlType(col)}${getTypeParams(col)}${def}`);
55660
+ else statements.push(`ALTER TABLE ${quoteIdentifier(tableName)} ADD COLUMN ${quoteIdentifier(col.name)} ${sqlType(col)}${getTypeParams(col)}${def}`);
55661
+ const colComment = buildColumnCommentStatement(col);
55662
+ if (colComment) statements.push(colComment);
55663
+ });
55664
+ diff.modifiedColumns.forEach((modification) => {
55665
+ const col = modification.newColumn;
55666
+ const def = buildColumnAttributes(col);
55667
+ if (isMySqlLike() && diff.renamedColumns.some((r) => r.oldColumn === modification.oldColumn)) return;
55668
+ if (isMySqlLike()) statements.push(`ALTER TABLE ${quoteIdentifier(tableName)} MODIFY COLUMN ${quoteIdentifier(col.name)} ${sqlType(col)}${getTypeParams(col)}${def}`);
55669
+ else if (isPostgresLike()) {
55670
+ statements.push(`ALTER TABLE ${quoteIdentifier(tableName)} ALTER COLUMN ${quoteIdentifier(col.name)} TYPE ${sqlType(col)}${getTypeParams(col)}`);
55671
+ statements.push(col.nullable ? `ALTER TABLE ${quoteIdentifier(tableName)} ALTER COLUMN ${quoteIdentifier(col.name)} DROP NOT NULL` : `ALTER TABLE ${quoteIdentifier(tableName)} ALTER COLUMN ${quoteIdentifier(col.name)} SET NOT NULL`);
55672
+ if (col.defaultValue) statements.push(`ALTER TABLE ${quoteIdentifier(tableName)} ALTER COLUMN ${quoteIdentifier(col.name)} SET DEFAULT ${formatDefaultValue(col.defaultValue, sqlType(col))}`);
55673
+ else statements.push(`ALTER TABLE ${quoteIdentifier(tableName)} ALTER COLUMN ${quoteIdentifier(col.name)} DROP DEFAULT`);
55674
+ } else if (dbType.value === "mssql" || dbType.value === "sqlserver") {
55675
+ statements.push(`ALTER TABLE ${quoteIdentifier(tableName)} ALTER COLUMN ${quoteIdentifier(col.name)} ${sqlType(col)}${getTypeParams(col)} ${col.nullable ? "NULL" : "NOT NULL"}`);
55676
+ if (col.defaultValue) statements.push(`ALTER TABLE ${quoteIdentifier(tableName)} ADD CONSTRAINT DF_${tableName}_${col.name} DEFAULT ${formatDefaultValue(col.defaultValue, sqlType(col))} FOR ${quoteIdentifier(col.name)}`);
55677
+ else statements.push(`ALTER TABLE ${quoteIdentifier(tableName)} DROP CONSTRAINT DF_${tableName}_${col.name}`);
55678
+ } else if (dbType.value === "oracle") statements.push(`ALTER TABLE ${quoteIdentifier(tableName)} MODIFY (${quoteIdentifier(col.name)} ${sqlType(col)}${getTypeParams(col)}${def})`);
55679
+ else if (dbType.value === "sqlite") statements.push(`-- SQLite 不支持直接修改列 "${col.name}",需要重建表`);
55680
+ const colComment = buildColumnCommentStatement(col);
55681
+ if (colComment) statements.push(colComment);
55682
+ });
55683
+ diff.deletedColumns.forEach((col) => {
55684
+ if (dbType.value === "sqlite") statements.push(`-- SQLite 不支持直接删除列 "${col.name}",需要重建表`);
55685
+ else statements.push(`ALTER TABLE ${quoteIdentifier(tableName)} DROP COLUMN ${quoteIdentifier(col.name)}`);
55686
+ });
55687
+ const oldPk = originalTableData.value.columns.filter((c) => c.isPrimary).map((c) => quoteIdentifier(c.name));
55688
+ const newPk = formData.value.columns.filter((c) => c.isPrimary && c.name).map((c) => quoteIdentifier(c.name));
55689
+ if (oldPk.join(",") !== newPk.join(",")) {
55690
+ if (isMySqlLike()) {
55691
+ statements.push(`ALTER TABLE ${quoteIdentifier(tableName)} DROP PRIMARY KEY`);
55692
+ statements.push(`ALTER TABLE ${quoteIdentifier(tableName)} ADD PRIMARY KEY (${newPk.join(", ")})`);
55693
+ } else if (isPostgresLike() || dbType.value === "oracle" || dbType.value === "mssql" || dbType.value === "sqlserver") {
55694
+ statements.push(`-- 需要先手动删除旧主键约束,再执行:`);
55695
+ statements.push(`ALTER TABLE ${quoteIdentifier(tableName)} ADD CONSTRAINT ${quoteIdentifier(`${tableName}_pkey`)} PRIMARY KEY (${newPk.join(", ")})`);
55696
+ } else if (dbType.value === "sqlite") statements.push(`-- SQLite 修改主键需要重建表`);
55697
+ }
55698
+ if (statements.length === 0) return "没有检测到任何修改";
55699
+ return statements.join(";\n") + ";";
55700
+ }
55701
+ }
55702
+ function buildColumnAttributes(col) {
55703
+ const type = sqlType(col);
55704
+ let sql = "";
55705
+ const isSqliteAutoIncrementPrimary = dbType.value === "sqlite" && col.isAutoIncrement && col.isPrimary;
55706
+ if (!col.nullable && !isSqliteAutoIncrementPrimary) sql += " NOT NULL";
55707
+ if (col.defaultValue) sql += ` DEFAULT ${formatDefaultValue(col.defaultValue, type)}`;
55708
+ if (col.isAutoIncrement) {
55709
+ if (isMySqlLike()) sql += " AUTO_INCREMENT";
55710
+ else if (isPostgresLike()) {
55711
+ if (!type.toLowerCase().includes("serial")) sql += " GENERATED ALWAYS AS IDENTITY";
55712
+ } else if (dbType.value === "sqlite") sql += col.isPrimary ? " PRIMARY KEY AUTOINCREMENT" : " AUTOINCREMENT";
55713
+ else if (dbType.value === "oracle") {
55714
+ if (type.toLowerCase().includes("number")) sql += " GENERATED BY DEFAULT AS IDENTITY";
55715
+ } else if (dbType.value === "mssql" || dbType.value === "sqlserver") sql += " IDENTITY(1,1)";
55716
+ }
55717
+ if (col.comment && isMySqlLike()) sql += ` COMMENT '${escapeSqlString(col.comment)}'`;
55718
+ return sql;
55719
+ }
55720
+ function buildColumnDefinition(col, quoteIdentifier) {
55721
+ return `${quoteIdentifier(col.name)} ${sqlType(col)}${getTypeParams(col)}${buildColumnAttributes(col)}`;
55722
+ }
55723
+ function buildColumnCommentStatement(col) {
55724
+ if (!col.comment) return "";
55725
+ const quoteIdentifier = getQuoter();
55726
+ if (isPostgresLike() || dbType.value === "oracle") return `COMMENT ON COLUMN ${quoteIdentifier(formData.value.tableName)}.${quoteIdentifier(col.name)} IS '${escapeSqlString(col.comment)}'`;
55727
+ if (dbType.value === "mssql" || dbType.value === "sqlserver") return `EXEC sp_addextendedproperty @name=N'MS_Description', @value=N'${escapeSqlString(col.comment)}', @level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'${escapeSqlString(formData.value.tableName)}', @level2type=N'COLUMN', @level2name=N'${escapeSqlString(col.name)}'`;
55728
+ return "";
55729
+ }
55730
+ function getQuoter() {
55731
+ return (name) => {
55732
+ if (!props.connection) return `"${name}"`;
55733
+ switch (dbType.value) {
55586
55734
  case "mysql":
55587
- sqlStatements.push(`ALTER TABLE ${quoteIdentifier(tableName)} COMMENT='${formData.value.tableComment}'`);
55588
- break;
55735
+ case "mariadb":
55736
+ case "aurora-mysql":
55737
+ case "auroramysql":
55738
+ case "clickhouse":
55739
+ case "click-house": return `\`${name}\``;
55589
55740
  case "postgres":
55590
- sqlStatements.push(`COMMENT ON TABLE ${quoteIdentifier(tableName)} IS '${formData.value.tableComment}'`);
55591
- break;
55592
- case "oracle":
55593
- sqlStatements.push(`COMMENT ON TABLE ${quoteIdentifier(tableName)} IS '${formData.value.tableComment}'`);
55594
- break;
55741
+ case "postgresql":
55742
+ case "cockroachdb":
55743
+ case "aurora-postgres":
55744
+ case "aurorapostgres":
55745
+ case "aurora-postgresql":
55746
+ case "sqlite": return `"${name}"`;
55747
+ case "oracle": return `"${name.toUpperCase()}"`;
55595
55748
  case "mssql":
55596
- sqlStatements.push(`EXEC sp_addextendedproperty 'MS_Description', '${formData.value.tableComment}', 'SCHEMA', 'dbo', 'TABLE', '${tableName}'`);
55597
- break;
55598
- }
55599
- formData.value.columns.forEach((col) => {
55600
- if (!col.name || !col.type) return;
55601
- let columnSQL = `${quoteIdentifier(col.name)} ${col.type}`;
55602
- if (!col.type.includes("(") && col.length && (needsLength(col) || col.type.includes("CHAR"))) columnSQL += `(${col.length})`;
55603
- else if (!col.type.includes("(") && col.precision) if (col.scale) columnSQL += `(${col.precision},${col.scale})`;
55604
- else columnSQL += `(${col.precision})`;
55605
- if (!col.nullable) columnSQL += " NOT NULL";
55606
- else columnSQL += " NULL";
55607
- if (col.defaultValue) columnSQL += ` DEFAULT ${formatDefaultValue(col.defaultValue, col.type)}`;
55608
- let commentStatement = "";
55609
- if (col.comment) switch (props.connection?.type.toLowerCase()) {
55610
- case "mysql":
55611
- columnSQL += ` COMMENT '${col.comment}'`;
55612
- break;
55613
- case "postgres":
55614
- commentStatement = `COMMENT ON COLUMN ${quoteIdentifier(tableName)}.${quoteIdentifier(col.name)} IS '${col.comment}'`;
55615
- break;
55616
- case "oracle":
55617
- columnSQL += ` COMMENT '${col.comment}'`;
55618
- break;
55619
- case "mssql":
55620
- commentStatement = `EXEC sp_addextendedproperty 'MS_Description', '${col.comment}', 'SCHEMA', 'dbo', 'TABLE', '${tableName}', 'COLUMN', '${col.name}'`;
55621
- break;
55622
- }
55623
- switch (props.connection?.type.toLowerCase()) {
55624
- case "mysql":
55625
- sqlStatements.push(`ALTER TABLE ${quoteIdentifier(tableName)} MODIFY COLUMN ${columnSQL}`);
55626
- break;
55627
- case "postgres":
55628
- case "mssql":
55629
- sqlStatements.push(`ALTER TABLE ${quoteIdentifier(tableName)} ALTER COLUMN ${columnSQL}`);
55630
- break;
55631
- case "oracle":
55632
- sqlStatements.push(`ALTER TABLE ${quoteIdentifier(tableName)} MODIFY ${columnSQL}`);
55633
- break;
55634
- case "sqlite":
55635
- sqlStatements.push(`-- SQLite 不支持直接修改列,需要重建表`);
55636
- break;
55637
- }
55638
- if (commentStatement) sqlStatements.push(commentStatement);
55639
- });
55640
- const primaryKeys = formData.value.columns.filter((col) => col.isPrimary).map((col) => quoteIdentifier(col.name));
55641
- if (primaryKeys.length > 0) {
55642
- sqlStatements.push(`ALTER TABLE ${quoteIdentifier(tableName)} DROP PRIMARY KEY`);
55643
- sqlStatements.push(`ALTER TABLE ${quoteIdentifier(tableName)} ADD PRIMARY KEY (${primaryKeys.join(", ")})`);
55644
- }
55645
- return sqlStatements.join(";\n") + ";";
55646
- }
55647
- }
55749
+ case "sqlserver": return `[${name}]`;
55750
+ default: return `"${name}"`;
55751
+ }
55752
+ };
55753
+ }
55754
+ const DEFAULT_KEYWORDS = /* @__PURE__ */ new Set([
55755
+ "current_timestamp",
55756
+ "now()",
55757
+ "current_date",
55758
+ "current_time",
55759
+ "localtimestamp",
55760
+ "localtime",
55761
+ "current_user",
55762
+ "sysdate",
55763
+ "systimestamp",
55764
+ "getdate()",
55765
+ "getutcdate()",
55766
+ "sysdatetime()",
55767
+ "sysdatetimeoffset()",
55768
+ "sysutcdatetime()",
55769
+ "newid()",
55770
+ "newsequentialid()",
55771
+ "gen_random_uuid()",
55772
+ "uuid_generate_v4()"
55773
+ ]);
55648
55774
  function formatDefaultValue(value, type) {
55649
55775
  if (value === null || value === void 0 || value === "") return "NULL";
55650
- const lowerValue = String(value).toLowerCase();
55651
- if ([
55652
- "current_timestamp",
55653
- "now()",
55654
- "current_date",
55655
- "current_time",
55656
- "localtimestamp",
55657
- "localtime"
55658
- ].includes(lowerValue)) return value;
55776
+ const raw = String(value).trim();
55777
+ const lower = raw.toLowerCase();
55778
+ if (lower === "null") return "NULL";
55779
+ if (DEFAULT_KEYWORDS.has(lower)) return raw;
55780
+ if (/^[a-z_][a-z0-9_]*\s*\(\s*\)$/.test(lower)) return raw;
55781
+ if (/^current_timestamp\s*\(\s*\d+\s*\)$/.test(lower)) return raw;
55659
55782
  const lowerType = type.toLowerCase();
55660
- if (isNumericType(lowerType) && !isNaN(value)) return String(value);
55783
+ if (isNumericType(lowerType) && !isNaN(Number(raw))) return raw;
55661
55784
  if (isBooleanType(lowerType)) return value ? "TRUE" : "FALSE";
55662
55785
  return `'${String(value).replace(/'/g, "''")}'`;
55663
55786
  }
@@ -55667,7 +55790,7 @@ var init_table_editor_vue_vue_type_script_setup_true_lang = __esmMin((() => {
55667
55790
  await modal.warning("请输入表名");
55668
55791
  return;
55669
55792
  }
55670
- if (formData.value.columns.some((col) => !col.name || !col.type)) {
55793
+ if (formData.value.columns.some((col) => !col.name || !rawType(col))) {
55671
55794
  await modal.warning("请完善所有字段信息");
55672
55795
  return;
55673
55796
  }
@@ -55681,7 +55804,7 @@ var init_table_editor_vue_vue_type_script_setup_true_lang = __esmMin((() => {
55681
55804
  result = await databaseService.executeQuery(props.connection.id, sql, props.database);
55682
55805
  } else {
55683
55806
  const tableDiff = calculateTableDiff();
55684
- if (tableDiff.addedColumns.length === 0 && tableDiff.modifiedColumns.length === 0 && tableDiff.deletedColumns.length === 0 && !tableDiff.tableCommentChanged) {
55807
+ if (tableDiff.addedColumns.length === 0 && tableDiff.modifiedColumns.length === 0 && tableDiff.deletedColumns.length === 0 && tableDiff.renamedColumns.length === 0 && !tableDiff.tableCommentChanged) {
55685
55808
  await modal.info("没有检测到任何修改");
55686
55809
  return;
55687
55810
  }
@@ -55724,9 +55847,16 @@ var init_table_editor_vue_vue_type_script_setup_true_lang = __esmMin((() => {
55724
55847
  }[category] || category;
55725
55848
  }
55726
55849
  function getSelectedType(column) {
55727
- if (!column.type) return null;
55728
- const typeName = column.type.match(/^[a-zA-Z]+/)?.[0] || column.type;
55729
- return columnTypes.value.find((t) => t.name.toLowerCase() === typeName.toLowerCase());
55850
+ const raw = rawType(column);
55851
+ if (!raw) return null;
55852
+ if (raw.includes("(")) return null;
55853
+ const lower = raw.trim().toLowerCase();
55854
+ let typeInfo = columnTypes.value.find((t) => t.name.toLowerCase() === lower);
55855
+ if (!typeInfo) {
55856
+ const typeName = lower.match(/^[a-zA-Z]+/)?.[0] || lower;
55857
+ typeInfo = columnTypes.value.find((t) => t.name.toLowerCase() === typeName);
55858
+ }
55859
+ return typeInfo || null;
55730
55860
  }
55731
55861
  function needsLength(column) {
55732
55862
  return getSelectedType(column)?.requiresLength || false;
@@ -55737,6 +55867,22 @@ var init_table_editor_vue_vue_type_script_setup_true_lang = __esmMin((() => {
55737
55867
  function needsScale(column) {
55738
55868
  return getSelectedType(column)?.requiresScale || false;
55739
55869
  }
55870
+ function getTypeParams(column) {
55871
+ const raw = rawType(column);
55872
+ if (!raw || raw.includes("(")) return "";
55873
+ const typeInfo = getSelectedType(column);
55874
+ if (typeInfo?.requiresPrecision) {
55875
+ const precision = column.precision || typeInfo.defaultPrecision;
55876
+ const scale = column.scale || typeInfo.defaultScale;
55877
+ if (precision == null) return "";
55878
+ return scale != null ? `(${precision},${scale})` : `(${precision})`;
55879
+ }
55880
+ if (typeInfo?.requiresLength) {
55881
+ const length = column.length || typeInfo.defaultLength;
55882
+ if (length != null) return `(${length})`;
55883
+ }
55884
+ return "";
55885
+ }
55740
55886
  function supportsAutoIncrement(column) {
55741
55887
  return getSelectedType(column)?.supportsAutoIncrement || false;
55742
55888
  }
@@ -55744,53 +55890,45 @@ var init_table_editor_vue_vue_type_script_setup_true_lang = __esmMin((() => {
55744
55890
  if (props.visible) initFormData();
55745
55891
  });
55746
55892
  return (_ctx, _cache) => {
55747
- return __props.visible ? (openBlock(), createElementBlock("div", {
55748
- key: 0,
55749
- class: "modal fade show",
55750
- style: {
55751
- "display": "block",
55752
- "background-color": "rgba(0,0,0,0.5)"
55753
- },
55754
- onClick: close
55755
- }, [createBaseVNode("div", {
55893
+ return __props.visible ? (openBlock(), createElementBlock("div", _hoisted_1$6, [createBaseVNode("div", {
55756
55894
  class: "modal-dialog modal-lg",
55757
55895
  style: {
55758
55896
  "width": "80%",
55759
55897
  "max-width": "none"
55760
55898
  },
55761
55899
  onClick: _cache[2] || (_cache[2] = withModifiers(() => {}, ["stop"]))
55762
- }, [createBaseVNode("div", _hoisted_1$6, [
55763
- createBaseVNode("div", _hoisted_2$6, [createBaseVNode("h5", _hoisted_3$6, [_cache[3] || (_cache[3] = createBaseVNode("i", { class: "bi bi-pencil-square me-2" }, null, -1)), createTextVNode(" " + toDisplayString(__props.mode === "create" ? _ctx.$t("tableEditor.createNewTable") : _ctx.$t("tableEditor.modifyStructure")), 1)]), createBaseVNode("button", {
55900
+ }, [createBaseVNode("div", _hoisted_2$6, [
55901
+ createBaseVNode("div", _hoisted_3$6, [createBaseVNode("h5", _hoisted_4$6, [_cache[3] || (_cache[3] = createBaseVNode("i", { class: "bi bi-pencil-square me-2" }, null, -1)), createTextVNode(" " + toDisplayString(__props.mode === "create" ? _ctx.$t("tableEditor.createNewTable") : _ctx.$t("tableEditor.modifyStructure")), 1)]), createBaseVNode("button", {
55764
55902
  type: "button",
55765
55903
  class: "btn-close",
55766
55904
  onClick: close
55767
55905
  })]),
55768
- createBaseVNode("div", _hoisted_4$6, [
55769
- createBaseVNode("div", _hoisted_5$6, [createBaseVNode("h6", _hoisted_6$6, toDisplayString(_ctx.$t("tableEditor.tableInfo")), 1), createBaseVNode("div", _hoisted_7$6, [createBaseVNode("div", _hoisted_8$6, [createBaseVNode("div", _hoisted_9$6, [createBaseVNode("label", _hoisted_10$6, toDisplayString(_ctx.$t("tableEditor.tableNameLabel")), 1), withDirectives(createBaseVNode("input", {
55906
+ createBaseVNode("div", _hoisted_5$6, [
55907
+ createBaseVNode("div", _hoisted_6$6, [createBaseVNode("h6", _hoisted_7$6, toDisplayString(_ctx.$t("tableEditor.tableInfo")), 1), createBaseVNode("div", _hoisted_8$6, [createBaseVNode("div", _hoisted_9$6, [createBaseVNode("div", _hoisted_10$6, [createBaseVNode("label", _hoisted_11$6, toDisplayString(_ctx.$t("tableEditor.tableNameLabel")), 1), withDirectives(createBaseVNode("input", {
55770
55908
  "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => formData.value.tableName = $event),
55771
55909
  type: "text",
55772
55910
  class: "form-control",
55773
55911
  disabled: __props.mode === "edit",
55774
55912
  placeholder: _ctx.$t("tableEditor.tableNamePlaceholder")
55775
- }, null, 8, _hoisted_11$6), [[vModelText, formData.value.tableName]])])]), createBaseVNode("div", _hoisted_12$6, [createBaseVNode("div", _hoisted_13$6, [createBaseVNode("label", _hoisted_14$6, toDisplayString(_ctx.$t("tableEditor.tableCommentLabel")), 1), withDirectives(createBaseVNode("input", {
55913
+ }, null, 8, _hoisted_12$6), [[vModelText, formData.value.tableName]])])]), createBaseVNode("div", _hoisted_13$6, [createBaseVNode("div", _hoisted_14$6, [createBaseVNode("label", _hoisted_15$6, toDisplayString(_ctx.$t("tableEditor.tableCommentLabel")), 1), withDirectives(createBaseVNode("input", {
55776
55914
  "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => formData.value.tableComment = $event),
55777
55915
  type: "text",
55778
55916
  class: "form-control",
55779
55917
  placeholder: _ctx.$t("tableEditor.tableCommentPlaceholder")
55780
- }, null, 8, _hoisted_15$6), [[vModelText, formData.value.tableComment]])])])])]),
55781
- createBaseVNode("div", _hoisted_16$6, [createBaseVNode("div", _hoisted_17$6, [createBaseVNode("h6", _hoisted_18$6, toDisplayString(_ctx.$t("tableEditor.columnManagement")), 1), createBaseVNode("button", {
55918
+ }, null, 8, _hoisted_16$6), [[vModelText, formData.value.tableComment]])])])])]),
55919
+ createBaseVNode("div", _hoisted_17$6, [createBaseVNode("div", _hoisted_18$6, [createBaseVNode("h6", _hoisted_19$6, toDisplayString(_ctx.$t("tableEditor.columnManagement")), 1), createBaseVNode("button", {
55782
55920
  class: "btn btn-success btn-sm",
55783
55921
  onClick: addColumn
55784
- }, [_cache[4] || (_cache[4] = createBaseVNode("i", { class: "bi bi-plus-lg" }, null, -1)), createTextVNode(" " + toDisplayString(_ctx.$t("tableEditor.addColumn")), 1)])]), createBaseVNode("div", _hoisted_19$6, [createBaseVNode("table", _hoisted_20$6, [createBaseVNode("thead", null, [createBaseVNode("tr", null, [
55785
- createBaseVNode("th", _hoisted_21$6, toDisplayString(_ctx.$t("tableEditor.columnNameHeader")), 1),
55786
- createBaseVNode("th", _hoisted_22$6, toDisplayString(_ctx.$t("tableEditor.dataTypeHeader")), 1),
55787
- createBaseVNode("th", _hoisted_23$6, toDisplayString(_ctx.$t("tableEditor.lengthPrecisionHeader")), 1),
55788
- createBaseVNode("th", _hoisted_24$6, toDisplayString(_ctx.$t("tableEditor.nullableHeader")), 1),
55789
- createBaseVNode("th", _hoisted_25$6, toDisplayString(_ctx.$t("tableEditor.defaultHeader")), 1),
55790
- createBaseVNode("th", _hoisted_26$5, toDisplayString(_ctx.$t("tableEditor.primaryKeyHeader")), 1),
55791
- createBaseVNode("th", _hoisted_27$5, toDisplayString(_ctx.$t("tableEditor.autoIncHeader")), 1),
55922
+ }, [_cache[4] || (_cache[4] = createBaseVNode("i", { class: "bi bi-plus-lg" }, null, -1)), createTextVNode(" " + toDisplayString(_ctx.$t("tableEditor.addColumn")), 1)])]), createBaseVNode("div", _hoisted_20$6, [createBaseVNode("table", _hoisted_21$6, [createBaseVNode("thead", null, [createBaseVNode("tr", null, [
55923
+ createBaseVNode("th", _hoisted_22$6, toDisplayString(_ctx.$t("tableEditor.columnNameHeader")), 1),
55924
+ createBaseVNode("th", _hoisted_23$6, toDisplayString(_ctx.$t("tableEditor.dataTypeHeader")), 1),
55925
+ createBaseVNode("th", _hoisted_24$6, toDisplayString(_ctx.$t("tableEditor.lengthPrecisionHeader")), 1),
55926
+ createBaseVNode("th", _hoisted_25$6, toDisplayString(_ctx.$t("tableEditor.nullableHeader")), 1),
55927
+ createBaseVNode("th", _hoisted_26$5, toDisplayString(_ctx.$t("tableEditor.defaultHeader")), 1),
55928
+ createBaseVNode("th", _hoisted_27$5, toDisplayString(_ctx.$t("tableEditor.primaryKeyHeader")), 1),
55929
+ createBaseVNode("th", _hoisted_28$5, toDisplayString(_ctx.$t("tableEditor.autoIncHeader")), 1),
55792
55930
  createBaseVNode("th", null, toDisplayString(_ctx.$t("tableEditor.commentHeader")), 1),
55793
- createBaseVNode("th", _hoisted_28$5, toDisplayString(_ctx.$t("tableEditor.operationsHeader")), 1)
55931
+ createBaseVNode("th", _hoisted_29$5, toDisplayString(_ctx.$t("tableEditor.operationsHeader")), 1)
55794
55932
  ])]), createBaseVNode("tbody", null, [(openBlock(true), createElementBlock(Fragment, null, renderList(formData.value.columns, (column, index) => {
55795
55933
  return openBlock(), createElementBlock("tr", { key: index }, [
55796
55934
  createBaseVNode("td", null, [withDirectives(createBaseVNode("input", {
@@ -55798,83 +55936,93 @@ var init_table_editor_vue_vue_type_script_setup_true_lang = __esmMin((() => {
55798
55936
  type: "text",
55799
55937
  class: "form-control form-control-sm",
55800
55938
  placeholder: _ctx.$t("tableEditor.columnNamePlaceholder")
55801
- }, null, 8, _hoisted_29$5), [[vModelText, column.name]])]),
55939
+ }, null, 8, _hoisted_30$4), [[vModelText, column.name]])]),
55802
55940
  createBaseVNode("td", null, [withDirectives(createBaseVNode("select", {
55803
55941
  "onUpdate:modelValue": ($event) => column.type = $event,
55804
55942
  class: "form-select form-select-sm"
55805
- }, [createBaseVNode("option", _hoisted_31$4, toDisplayString(_ctx.$t("tableEditor.selectType")), 1), (openBlock(true), createElementBlock(Fragment, null, renderList(columnTypesByCategory.value, (types, category) => {
55806
- return openBlock(), createElementBlock("optgroup", {
55807
- key: category,
55808
- label: getCategoryLabel(category)
55809
- }, [(openBlock(true), createElementBlock(Fragment, null, renderList(types, (type) => {
55810
- return openBlock(), createElementBlock("option", {
55811
- key: type.name,
55812
- value: type.name
55813
- }, toDisplayString(type.label), 9, _hoisted_33$4);
55814
- }), 128))], 8, _hoisted_32$4);
55815
- }), 128))], 8, _hoisted_30$4), [[vModelSelect, column.type]])]),
55816
- createBaseVNode("td", null, [needsLength(column) || needsPrecision(column) ? (openBlock(), createElementBlock("div", _hoisted_34$4, [
55943
+ }, [
55944
+ createBaseVNode("option", _hoisted_32$4, toDisplayString(_ctx.$t("tableEditor.selectType")), 1),
55945
+ (openBlock(true), createElementBlock(Fragment, null, renderList(columnTypesByCategory.value, (types, category) => {
55946
+ return openBlock(), createElementBlock("optgroup", {
55947
+ key: category,
55948
+ label: getCategoryLabel(category)
55949
+ }, [(openBlock(true), createElementBlock(Fragment, null, renderList(types, (type) => {
55950
+ return openBlock(), createElementBlock("option", {
55951
+ key: type.name,
55952
+ value: type.name
55953
+ }, toDisplayString(type.label), 9, _hoisted_34$4);
55954
+ }), 128))], 8, _hoisted_33$4);
55955
+ }), 128)),
55956
+ createBaseVNode("option", { value: CUSTOM_TYPE_VALUE }, toDisplayString(_ctx.$t("tableEditor.customType")), 1)
55957
+ ], 8, _hoisted_31$4), [[vModelSelect, column.type]]), column.type === CUSTOM_TYPE_VALUE ? withDirectives((openBlock(), createElementBlock("input", {
55958
+ key: 0,
55959
+ "onUpdate:modelValue": ($event) => column.customType = $event,
55960
+ type: "text",
55961
+ class: "form-control form-control-sm mt-1",
55962
+ placeholder: _ctx.$t("tableEditor.customTypePlaceholder")
55963
+ }, null, 8, _hoisted_35$4)), [[vModelText, column.customType]]) : createCommentVNode("", true)]),
55964
+ createBaseVNode("td", null, [needsLength(column) || needsPrecision(column) ? (openBlock(), createElementBlock("div", _hoisted_36$4, [
55817
55965
  needsLength(column) ? withDirectives((openBlock(), createElementBlock("input", {
55818
55966
  key: 0,
55819
55967
  "onUpdate:modelValue": ($event) => column.length = $event,
55820
55968
  type: "number",
55821
55969
  class: "form-control form-control-sm",
55822
55970
  placeholder: _ctx.$t("tableEditor.lengthPlaceholder")
55823
- }, null, 8, _hoisted_35$4)), [[vModelText, column.length]]) : createCommentVNode("", true),
55971
+ }, null, 8, _hoisted_37$4)), [[vModelText, column.length]]) : createCommentVNode("", true),
55824
55972
  needsPrecision(column) ? withDirectives((openBlock(), createElementBlock("input", {
55825
55973
  key: 1,
55826
55974
  "onUpdate:modelValue": ($event) => column.precision = $event,
55827
55975
  type: "number",
55828
55976
  class: "form-control form-control-sm",
55829
55977
  placeholder: _ctx.$t("tableEditor.precisionPlaceholder")
55830
- }, null, 8, _hoisted_36$4)), [[vModelText, column.precision]]) : createCommentVNode("", true),
55978
+ }, null, 8, _hoisted_38$4)), [[vModelText, column.precision]]) : createCommentVNode("", true),
55831
55979
  needsScale(column) ? withDirectives((openBlock(), createElementBlock("input", {
55832
55980
  key: 2,
55833
55981
  "onUpdate:modelValue": ($event) => column.scale = $event,
55834
55982
  type: "number",
55835
55983
  class: "form-control form-control-sm",
55836
55984
  placeholder: _ctx.$t("tableEditor.scalePlaceholder")
55837
- }, null, 8, _hoisted_37$4)), [[vModelText, column.scale]]) : createCommentVNode("", true)
55838
- ])) : (openBlock(), createElementBlock("span", _hoisted_38$4, "-"))]),
55839
- createBaseVNode("td", null, [createBaseVNode("div", _hoisted_39$4, [withDirectives(createBaseVNode("input", {
55985
+ }, null, 8, _hoisted_39$4)), [[vModelText, column.scale]]) : createCommentVNode("", true)
55986
+ ])) : (openBlock(), createElementBlock("span", _hoisted_40$4, "-"))]),
55987
+ createBaseVNode("td", null, [createBaseVNode("div", _hoisted_41$4, [withDirectives(createBaseVNode("input", {
55840
55988
  "onUpdate:modelValue": ($event) => column.nullable = $event,
55841
55989
  type: "checkbox",
55842
55990
  class: "form-check-input"
55843
- }, null, 8, _hoisted_40$4), [[vModelCheckbox, column.nullable]])])]),
55991
+ }, null, 8, _hoisted_42$4), [[vModelCheckbox, column.nullable]])])]),
55844
55992
  createBaseVNode("td", null, [withDirectives(createBaseVNode("input", {
55845
55993
  "onUpdate:modelValue": ($event) => column.defaultValue = $event,
55846
55994
  type: "text",
55847
55995
  class: "form-control form-control-sm",
55848
55996
  placeholder: _ctx.$t("tableEditor.defaultHeader")
55849
- }, null, 8, _hoisted_41$4), [[vModelText, column.defaultValue]])]),
55850
- createBaseVNode("td", null, [createBaseVNode("div", _hoisted_42$4, [withDirectives(createBaseVNode("input", {
55997
+ }, null, 8, _hoisted_43$4), [[vModelText, column.defaultValue]])]),
55998
+ createBaseVNode("td", null, [createBaseVNode("div", _hoisted_44$4, [withDirectives(createBaseVNode("input", {
55851
55999
  "onUpdate:modelValue": ($event) => column.isPrimary = $event,
55852
56000
  type: "checkbox",
55853
56001
  class: "form-check-input",
55854
56002
  onChange: ($event) => onPrimaryKeyChange(column, index)
55855
- }, null, 40, _hoisted_43$4), [[vModelCheckbox, column.isPrimary]])])]),
55856
- createBaseVNode("td", null, [createBaseVNode("div", _hoisted_44$4, [withDirectives(createBaseVNode("input", {
56003
+ }, null, 40, _hoisted_45$4), [[vModelCheckbox, column.isPrimary]])])]),
56004
+ createBaseVNode("td", null, [createBaseVNode("div", _hoisted_46$4, [withDirectives(createBaseVNode("input", {
55857
56005
  "onUpdate:modelValue": ($event) => column.isAutoIncrement = $event,
55858
56006
  type: "checkbox",
55859
56007
  class: "form-check-input",
55860
56008
  disabled: !column.isPrimary || !supportsAutoIncrement(column)
55861
- }, null, 8, _hoisted_45$4), [[vModelCheckbox, column.isAutoIncrement]])])]),
56009
+ }, null, 8, _hoisted_47$4), [[vModelCheckbox, column.isAutoIncrement]])])]),
55862
56010
  createBaseVNode("td", null, [withDirectives(createBaseVNode("input", {
55863
56011
  "onUpdate:modelValue": ($event) => column.comment = $event,
55864
56012
  type: "text",
55865
56013
  class: "form-control form-control-sm",
55866
56014
  placeholder: _ctx.$t("tableEditor.fieldComment")
55867
- }, null, 8, _hoisted_46$4), [[vModelText, column.comment]])]),
56015
+ }, null, 8, _hoisted_48$3), [[vModelText, column.comment]])]),
55868
56016
  createBaseVNode("td", null, [createBaseVNode("button", {
55869
56017
  class: "btn btn-outline-danger btn-sm",
55870
56018
  onClick: ($event) => removeColumn(index),
55871
56019
  disabled: formData.value.columns.length <= 1
55872
- }, [..._cache[5] || (_cache[5] = [createBaseVNode("i", { class: "bi bi-trash" }, null, -1)])], 8, _hoisted_47$4)])
56020
+ }, [..._cache[5] || (_cache[5] = [createBaseVNode("i", { class: "bi bi-trash" }, null, -1)])], 8, _hoisted_49$3)])
55873
56021
  ]);
55874
56022
  }), 128))])])])]),
55875
- createBaseVNode("div", _hoisted_48$3, [createBaseVNode("h6", _hoisted_49$3, toDisplayString(_ctx.$t("tableEditor.sqlPreview")), 1), createBaseVNode("pre", _hoisted_50$3, toDisplayString(generateSQL()), 1)])
56023
+ createBaseVNode("div", _hoisted_50$3, [createBaseVNode("h6", _hoisted_51$3, toDisplayString(_ctx.$t("tableEditor.sqlPreview")), 1), createBaseVNode("pre", _hoisted_52$3, toDisplayString(generateSQL()), 1)])
55876
56024
  ]),
55877
- createBaseVNode("div", _hoisted_51$3, [createBaseVNode("button", {
56025
+ createBaseVNode("div", _hoisted_53$3, [createBaseVNode("button", {
55878
56026
  type: "button",
55879
56027
  class: "btn btn-secondary",
55880
56028
  onClick: close
@@ -55889,17 +56037,17 @@ var init_table_editor_vue_vue_type_script_setup_true_lang = __esmMin((() => {
55889
56037
  });
55890
56038
  }));
55891
56039
  //#endregion
55892
- //#region src/platform/database/components/table-editor.vue?vue&type=style&index=0&scoped=0d3b1052&lang.css
55893
- var init_table_editor_vue_vue_type_style_index_0_scoped_0d3b1052_lang = __esmMin((() => {}));
56040
+ //#region src/platform/database/components/table-editor.vue?vue&type=style&index=0&scoped=b80d5611&lang.css
56041
+ var init_table_editor_vue_vue_type_style_index_0_scoped_b80d5611_lang = __esmMin((() => {}));
55894
56042
  //#endregion
55895
56043
  //#region src/platform/database/components/table-editor.vue
55896
56044
  var table_editor_default;
55897
56045
  var init_table_editor = __esmMin((() => {
55898
56046
  init_table_editor_vue_vue_type_script_setup_true_lang();
55899
56047
  init_table_editor_vue_vue_type_script_setup_true_lang();
55900
- init_table_editor_vue_vue_type_style_index_0_scoped_0d3b1052_lang();
56048
+ init_table_editor_vue_vue_type_style_index_0_scoped_b80d5611_lang();
55901
56049
  init__plugin_vue_export_helper();
55902
- table_editor_default = /*#__PURE__*/ _plugin_vue_export_helper_default(table_editor_vue_vue_type_script_setup_true_lang_default, [["__scopeId", "data-v-0d3b1052"]]);
56050
+ table_editor_default = /*#__PURE__*/ _plugin_vue_export_helper_default(table_editor_vue_vue_type_script_setup_true_lang_default, [["__scopeId", "data-v-b80d5611"]]);
55903
56051
  }));
55904
56052
  //#endregion
55905
56053
  //#region src/platform/database/components/db-tools.vue?vue&type=script&setup=true&lang.ts
@@ -56636,7 +56784,7 @@ var init_db_tools_vue_vue_type_script_setup_true_lang = __esmMin((() => {
56636
56784
  createBaseVNode("div", _hoisted_53$2, [createBaseVNode("label", _hoisted_54$2, toDisplayString(_ctx.$t("dbTools.dbTypeLabel")), 1), withDirectives(createBaseVNode("select", {
56637
56785
  class: "form-select",
56638
56786
  "onUpdate:modelValue": _cache[7] || (_cache[7] = ($event) => syncConfig.value.target.dbType = $event)
56639
- }, [..._cache[51] || (_cache[51] = [createStaticVNode("<option value=\"mysql\" data-v-c49117ce>MySQL</option><option value=\"postgresql\" data-v-c49117ce>PostgreSQL</option><option value=\"sqlite\" data-v-c49117ce>SQLite</option><option value=\"sqlserver\" data-v-c49117ce>SQL Server</option><option value=\"oracle\" data-v-c49117ce>Oracle</option>", 5)])], 512), [[vModelSelect, syncConfig.value.target.dbType]])]),
56787
+ }, [..._cache[51] || (_cache[51] = [createStaticVNode("<option value=\"mysql\" data-v-a123948c>MySQL</option><option value=\"postgresql\" data-v-a123948c>PostgreSQL</option><option value=\"sqlite\" data-v-a123948c>SQLite</option><option value=\"sqlserver\" data-v-a123948c>SQL Server</option><option value=\"oracle\" data-v-a123948c>Oracle</option>", 5)])], 512), [[vModelSelect, syncConfig.value.target.dbType]])]),
56640
56788
  createBaseVNode("div", _hoisted_55$2, [createBaseVNode("label", _hoisted_56$2, toDisplayString(_ctx.$t("dbTools.hostLabel")), 1), withDirectives(createBaseVNode("input", {
56641
56789
  type: "text",
56642
56790
  class: "form-control",
@@ -56776,17 +56924,17 @@ var init_db_tools_vue_vue_type_script_setup_true_lang = __esmMin((() => {
56776
56924
  });
56777
56925
  }));
56778
56926
  //#endregion
56779
- //#region src/platform/database/components/db-tools.vue?vue&type=style&index=0&scoped=c49117ce&lang.css
56780
- var init_db_tools_vue_vue_type_style_index_0_scoped_c49117ce_lang = __esmMin((() => {}));
56927
+ //#region src/platform/database/components/db-tools.vue?vue&type=style&index=0&scoped=a123948c&lang.css
56928
+ var init_db_tools_vue_vue_type_style_index_0_scoped_a123948c_lang = __esmMin((() => {}));
56781
56929
  //#endregion
56782
56930
  //#region src/platform/database/components/db-tools.vue
56783
56931
  var db_tools_default;
56784
56932
  var init_db_tools = __esmMin((() => {
56785
56933
  init_db_tools_vue_vue_type_script_setup_true_lang();
56786
56934
  init_db_tools_vue_vue_type_script_setup_true_lang();
56787
- init_db_tools_vue_vue_type_style_index_0_scoped_c49117ce_lang();
56935
+ init_db_tools_vue_vue_type_style_index_0_scoped_a123948c_lang();
56788
56936
  init__plugin_vue_export_helper();
56789
- db_tools_default = /*#__PURE__*/ _plugin_vue_export_helper_default(db_tools_vue_vue_type_script_setup_true_lang_default, [["__scopeId", "data-v-c49117ce"]]);
56937
+ db_tools_default = /*#__PURE__*/ _plugin_vue_export_helper_default(db_tools_vue_vue_type_script_setup_true_lang_default, [["__scopeId", "data-v-a123948c"]]);
56790
56938
  }));
56791
56939
  //#endregion
56792
56940
  //#region src/platform/database/components/database-detail.vue?vue&type=script&setup=true&lang.ts
@@ -57008,7 +57156,8 @@ var init_database_detail_vue_vue_type_script_setup_true_lang = __esmMin((() => {
57008
57156
  const procedures = ref([]);
57009
57157
  const editingProcedure = ref(null);
57010
57158
  const showTableEditor = ref(false);
57011
- const editingTableName = ref("");
57159
+ const tableEditorMode = ref("create");
57160
+ const editingTable = ref(null);
57012
57161
  const tables = computed(() => {
57013
57162
  return props.tables || [];
57014
57163
  });
@@ -57045,21 +57194,39 @@ var init_database_detail_vue_vue_type_script_setup_true_lang = __esmMin((() => {
57045
57194
  }
57046
57195
  function createTable() {
57047
57196
  if (!newTable.value.name.trim()) return;
57048
- editingTableName.value = newTable.value.name;
57197
+ tableEditorMode.value = "create";
57198
+ editingTable.value = {
57199
+ name: newTable.value.name,
57200
+ comment: newTable.value.comment,
57201
+ rowCount: 0,
57202
+ dataSize: 0,
57203
+ indexSize: 0,
57204
+ columns: []
57205
+ };
57049
57206
  showTableEditor.value = true;
57050
57207
  showCreateTable.value = false;
57051
57208
  }
57052
- function editTable(table) {
57053
- editingTableName.value = table.name;
57054
- showTableEditor.value = true;
57209
+ async function editTable(table) {
57210
+ if (!props.connection?.id) return;
57211
+ try {
57212
+ const response = await databaseService.getTableInfo(props.connection.id, props.database, table.name);
57213
+ editingTable.value = response.data || null;
57214
+ tableEditorMode.value = "edit";
57215
+ showTableEditor.value = true;
57216
+ } catch (error) {
57217
+ console.error("获取表结构失败:", error);
57218
+ modal.error(t("databaseDetail.getTableInfoFailed"));
57219
+ }
57055
57220
  }
57056
57221
  function createNewTable() {
57057
- editingTableName.value = "";
57222
+ tableEditorMode.value = "create";
57223
+ editingTable.value = null;
57058
57224
  showTableEditor.value = true;
57059
57225
  }
57060
57226
  function closeTableEditor() {
57061
57227
  showTableEditor.value = false;
57062
- editingTableName.value = "";
57228
+ tableEditorMode.value = "create";
57229
+ editingTable.value = null;
57063
57230
  }
57064
57231
  onMounted(() => {
57065
57232
  if (props.connection?.id && props.database) {
@@ -57463,8 +57630,8 @@ var init_database_detail_vue_vue_type_script_setup_true_lang = __esmMin((() => {
57463
57630
  visible: showTableEditor.value,
57464
57631
  connection: __props.connection,
57465
57632
  database: __props.database,
57466
- "table-name": editingTableName.value,
57467
- mode: editingTableName.value ? "edit" : "create",
57633
+ table: editingTable.value,
57634
+ mode: tableEditorMode.value,
57468
57635
  onClose: closeTableEditor,
57469
57636
  onSubmit: handleTableChange,
57470
57637
  onExecuteSql: handleExecuteSQL
@@ -57472,7 +57639,7 @@ var init_database_detail_vue_vue_type_script_setup_true_lang = __esmMin((() => {
57472
57639
  "visible",
57473
57640
  "connection",
57474
57641
  "database",
57475
- "table-name",
57642
+ "table",
57476
57643
  "mode"
57477
57644
  ])
57478
57645
  ]);
@@ -57481,17 +57648,17 @@ var init_database_detail_vue_vue_type_script_setup_true_lang = __esmMin((() => {
57481
57648
  });
57482
57649
  }));
57483
57650
  //#endregion
57484
- //#region src/platform/database/components/database-detail.vue?vue&type=style&index=0&scoped=822c95b7&lang.css
57485
- var init_database_detail_vue_vue_type_style_index_0_scoped_822c95b7_lang = __esmMin((() => {}));
57651
+ //#region src/platform/database/components/database-detail.vue?vue&type=style&index=0&scoped=a6f90f39&lang.css
57652
+ var init_database_detail_vue_vue_type_style_index_0_scoped_a6f90f39_lang = __esmMin((() => {}));
57486
57653
  //#endregion
57487
57654
  //#region src/platform/database/components/database-detail.vue
57488
57655
  var database_detail_default;
57489
57656
  var init_database_detail = __esmMin((() => {
57490
57657
  init_database_detail_vue_vue_type_script_setup_true_lang();
57491
57658
  init_database_detail_vue_vue_type_script_setup_true_lang();
57492
- init_database_detail_vue_vue_type_style_index_0_scoped_822c95b7_lang();
57659
+ init_database_detail_vue_vue_type_style_index_0_scoped_a6f90f39_lang();
57493
57660
  init__plugin_vue_export_helper();
57494
- database_detail_default = /*#__PURE__*/ _plugin_vue_export_helper_default(database_detail_vue_vue_type_script_setup_true_lang_default, [["__scopeId", "data-v-822c95b7"]]);
57661
+ database_detail_default = /*#__PURE__*/ _plugin_vue_export_helper_default(database_detail_vue_vue_type_script_setup_true_lang_default, [["__scopeId", "data-v-a6f90f39"]]);
57495
57662
  }));
57496
57663
  //#endregion
57497
57664
  //#region src/platform/database/components/data-editor.vue?vue&type=script&setup=true&lang.ts