@rebasepro/studio 0.12.0 → 0.12.1-canary.gdfba2a1

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.
@@ -881,7 +881,10 @@ var SQLEditor = () => {
881
881
  }
882
882
  } catch (err) {
883
883
  console.error("Failed to fetch databases or roles:", err);
884
- if (mounted) setConnectionConfigError(t("studio_sql_fetch_error", { message: err instanceof Error ? err.message : String(err) }));
884
+ if (mounted) {
885
+ const message = err instanceof Error ? err.message : String(err);
886
+ setConnectionConfigError(t("studio_sql_fetch_error", { message }));
887
+ }
885
888
  } finally {
886
889
  if (mounted) setIsLoadingConfig(false);
887
890
  }
@@ -967,7 +970,7 @@ var SQLEditor = () => {
967
970
  c.table_schema, c.table_name, c.ordinal_position;
968
971
  `, { database: selectedDatabase });
969
972
  const processGrouped = (data) => {
970
- setSchemas(data.reduce((acc, curr) => {
973
+ const grouped = data.reduce((acc, curr) => {
971
974
  const schema = curr.schema || curr.SCHEMA || curr.table_schema || "public";
972
975
  const table = curr.table || curr.TABLE || curr.table_name;
973
976
  const column = curr.column || curr.COLUMN || curr.column_name;
@@ -989,7 +992,8 @@ var SQLEditor = () => {
989
992
  isPrimaryKey
990
993
  });
991
994
  return acc;
992
- }, {}));
995
+ }, {});
996
+ setSchemas(grouped);
993
997
  };
994
998
  if (!result || !Array.isArray(result)) if (result && typeof result === "object" && "rows" in result && Array.isArray(result.rows)) processGrouped(result.rows);
995
999
  else {
@@ -1003,7 +1007,8 @@ var SQLEditor = () => {
1003
1007
  schemaFetchedRef.current = true;
1004
1008
  } catch (e) {
1005
1009
  console.error("Schema fetch error:", e);
1006
- setSchemaError(t("studio_sql_schema_fetch_error", { message: e instanceof Error ? e.message : String(e) }));
1010
+ const message = e instanceof Error ? e.message : String(e);
1011
+ setSchemaError(t("studio_sql_schema_fetch_error", { message }));
1007
1012
  } finally {
1008
1013
  setIsSchemaLoading(false);
1009
1014
  }
@@ -1213,7 +1218,8 @@ var SQLEditor = () => {
1213
1218
  });
1214
1219
  }, [activeTab.sql, projectPrefix]);
1215
1220
  const handlePrettify = () => {
1216
- setSql(activeTab.sql.replace(/\s+/g, " ").replace(/\s?,\s?/g, ", ").replace(/\s?=\s?/g, " = ").trim());
1221
+ const formatted = activeTab.sql.replace(/\s+/g, " ").replace(/\s?,\s?/g, ", ").replace(/\s?=\s?/g, " = ").trim();
1222
+ setSql(formatted);
1217
1223
  };
1218
1224
  const handleExplain = async () => {
1219
1225
  const explainSql = `EXPLAIN (FORMAT JSON, ANALYZE) ${activeTab.sql}`;
@@ -1224,15 +1230,19 @@ var SQLEditor = () => {
1224
1230
  });
1225
1231
  const start = performance.now();
1226
1232
  try {
1227
- if (databaseAdmin?.executeSql) updateActiveTab({
1228
- results: await databaseAdmin.executeSql(explainSql, {
1233
+ if (databaseAdmin?.executeSql) {
1234
+ const result = await databaseAdmin.executeSql(explainSql, {
1229
1235
  database: selectedDatabase,
1230
1236
  role: selectedRole
1231
- }),
1232
- execTime: Math.round(performance.now() - start)
1233
- });
1237
+ });
1238
+ updateActiveTab({
1239
+ results: result,
1240
+ execTime: Math.round(performance.now() - start)
1241
+ });
1242
+ }
1234
1243
  } catch (e) {
1235
- updateActiveTab({ error: (e instanceof Error ? e.message : String(e)) || t("studio_sql_error_explaining") });
1244
+ const message = e instanceof Error ? e.message : String(e);
1245
+ updateActiveTab({ error: message || t("studio_sql_error_explaining") });
1236
1246
  } finally {
1237
1247
  updateActiveTab({ loading: false });
1238
1248
  }
@@ -1254,18 +1264,20 @@ var SQLEditor = () => {
1254
1264
  const start = performance.now();
1255
1265
  try {
1256
1266
  if (databaseAdmin?.executeSql) {
1267
+ const result = await databaseAdmin.executeSql(sqlToRun, {
1268
+ database: selectedDatabase,
1269
+ role: selectedRole
1270
+ });
1257
1271
  updateActiveTab({
1258
- results: await databaseAdmin.executeSql(sqlToRun, {
1259
- database: selectedDatabase,
1260
- role: selectedRole
1261
- }),
1272
+ results: result,
1262
1273
  execTime: Math.round(performance.now() - start),
1263
1274
  lastExecutedSql: sqlToRun
1264
1275
  });
1265
1276
  if (history[history.length - 1] !== activeTab.sql) saveHistory([...history, activeTab.sql]);
1266
1277
  } else updateActiveTab({ error: t("studio_sql_execution_not_supported") });
1267
1278
  } catch (e) {
1268
- updateActiveTab({ error: (e instanceof Error ? e.message : String(e)) || t("studio_sql_error_executing") });
1279
+ const message = e instanceof Error ? e.message : String(e);
1280
+ updateActiveTab({ error: message || t("studio_sql_error_executing") });
1269
1281
  } finally {
1270
1282
  updateActiveTab({ loading: false });
1271
1283
  }
@@ -1961,4 +1973,4 @@ var SQLEditor = () => {
1961
1973
  //#endregion
1962
1974
  export { SQLEditor };
1963
1975
 
1964
- //# sourceMappingURL=SQLEditor-DFYk9r1u.js.map
1976
+ //# sourceMappingURL=SQLEditor-CL6DcGRM.js.map