Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/components/editor/QueryToolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
import { useEffect, useRef, useState } from "react";
import { format } from "sql-formatter";
import { useQueryExecution } from "../../hooks/useQueryExecution";
import { useSchemaCache } from "../../hooks/useSchemaCache";
import { useSchemaCacheStore } from "../../stores/schemaCacheStore";
import { postProcessSQL } from "../../lib/sql-post-process";
import { useAiStore } from "../../stores/aiStore";
import { useConnectionStore } from "../../stores/connectionStore";
Expand Down Expand Up @@ -46,8 +46,8 @@ export function QueryToolbar() {
(s) => s.selectedConnectionId,
);
const activeConnections = useConnectionStore((s) => s.activeConnections);
const refreshSchema = useSchemaCache((s) => s.refreshSchema);
const schemaLoading = useSchemaCache((s) => s.loading);
const refreshSchema = useSchemaCacheStore((s) => s.refreshSchema);
const schemaLoading = useSchemaCacheStore((s) => s.loading);

const {
executeQuery,
Expand Down
6 changes: 3 additions & 3 deletions src/components/editor/SQLEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Editor, { type OnMount, useMonaco } from "@monaco-editor/react";
import type { editor, IDisposable } from "monaco-editor";
import { useCallback, useEffect, useRef } from "react";
import { format } from "sql-formatter";
import { useSchemaCache } from "../../hooks/useSchemaCache";
import { useSchemaCacheStore } from "../../stores/schemaCacheStore";
import { createCompletionProvider } from "../../lib/schema-completion-provider";
import { postProcessSQL } from "../../lib/sql-post-process";
import { getStatementAtCursor } from "../../lib/statement-at-cursor";
Expand Down Expand Up @@ -47,7 +47,7 @@ export function SQLEditor() {
const selectedConnectionId = useConnectionStore(
(s) => s.selectedConnectionId,
);
const schemaCache = useSchemaCache();
const schemaCache = useSchemaCacheStore();

// Sync schema cache with active connection
useEffect(() => {
Expand Down Expand Up @@ -274,7 +274,7 @@ export function SQLEditor() {
64,
],
run: async () => {
await useSchemaCache.getState().refreshSchema();
await useSchemaCacheStore.getState().refreshSchema();
},
});

Expand Down
4 changes: 2 additions & 2 deletions src/components/editor/__tests__/QueryToolbar.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ vi.mock("../../../hooks/useQueryExecution", () => ({
const mockRefreshSchema = vi.fn().mockResolvedValue(undefined);
let mockSchemaLoading = false;

vi.mock("../../../hooks/useSchemaCache", () => ({
useSchemaCache: vi.fn(() => ({
vi.mock("../../../stores/schemaCacheStore", () => ({
useSchemaCacheStore: vi.fn(() => ({
refreshSchema: mockRefreshSchema,
loading: mockSchemaLoading,
connectionId: "conn-1",
Expand Down
10 changes: 5 additions & 5 deletions src/components/editor/__tests__/SQLEditor.browser.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ vi.mock("../../stores/resultStore", () => ({
),
}));

vi.mock("../../hooks/useSchemaCache", () => ({
useSchemaCache: vi.fn(() => ({
vi.mock("../../stores/schemaCacheStore", () => ({
useSchemaCacheStore: vi.fn(() => ({
connectionId: "conn-1",
databases: [],
tables: [],
Expand Down Expand Up @@ -214,8 +214,8 @@ vi.mock("../../stores/themeStore", () => ({
}),
}));

vi.mock("../../hooks/useSchemaCache", () => ({
useSchemaCache: vi.fn((selector?: (s: object) => unknown) => {
vi.mock("../../stores/schemaCacheStore", () => ({
useSchemaCacheStore: vi.fn((selector?: (s: object) => unknown) => {
const state = {
connectionId: null,
databases: [],
Expand Down Expand Up @@ -308,7 +308,7 @@ describe("SQLEditor (browser)", () => {
expect(m.mockExecuteExplainAnalyze).toHaveBeenCalledWith("conn-1", "SELECT 1", undefined);
});

it("refresh-schema.run calls useSchemaCache.refreshSchema", async () => {
it("refresh-schema.run calls useSchemaCacheStore.refreshSchema", async () => {
render(<SQLEditor />);
await waitFor(() => {
expect(m.capturedActions.some((a) => a.id === "refresh-schema")).toBe(true);
Expand Down
4 changes: 2 additions & 2 deletions src/components/editor/__tests__/SQLEditor.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ vi.mock("../../../stores/settingsStore", () => ({
}));

// Mock schema cache store
vi.mock("../../../hooks/useSchemaCache", () => ({
useSchemaCache: vi.fn((selector?: (s: any) => any) => {
vi.mock("../../../stores/schemaCacheStore", () => ({
useSchemaCacheStore: vi.fn((selector?: (s: any) => any) => {
const state = {
connectionId: null,
databases: [],
Expand Down
4 changes: 2 additions & 2 deletions src/components/layout/AppLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { getCurrentWindow } from "@tauri-apps/api/window";
import { useCallback, useEffect, useState } from "react";
import { Group, Panel, Separator } from "react-resizable-panels";
import { useKeyboardShortcuts } from "../../hooks/useKeyboardShortcuts";
import { useSchemaCache } from "../../hooks/useSchemaCache";
import { useSchemaCacheStore } from "../../stores/schemaCacheStore";
import { useTheme } from "../../hooks/useTheme";
import { useAiStore } from "../../stores/aiStore";
import { useConnectionStore } from "../../stores/connectionStore";
Expand Down Expand Up @@ -140,7 +140,7 @@ export function AppLayout() {
if (selectedConnectionId) disconnect(selectedConnectionId);
break;
case "refresh-schema":
useSchemaCache.getState().refreshSchema();
useSchemaCacheStore.getState().refreshSchema();
break;
case "compare-schemas":
addCompareTab();
Expand Down
8 changes: 4 additions & 4 deletions src/components/layout/__tests__/AppLayout.browser.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ vi.mock("../../../hooks/useKeyboardShortcuts", () => ({
vi.mock("../../../hooks/useTheme", () => ({
useTheme: vi.fn(),
}));
vi.mock("../../../hooks/useSchemaCache", () => ({
useSchemaCache: {
vi.mock("../../../stores/schemaCacheStore", () => ({
useSchemaCacheStore: {
getState: vi.fn(() => ({ refreshSchema: vi.fn() })),
},
}));
Expand Down Expand Up @@ -652,8 +652,8 @@ describe("AppLayout (browser)", () => {
// ─── Menu action: refresh-schema ───
it("handles refresh-schema menu action", async () => {
const refreshSpy = vi.fn();
const schemaCacheModule = await import("../../../hooks/useSchemaCache");
vi.mocked(schemaCacheModule.useSchemaCache.getState).mockReturnValue({ refreshSchema: refreshSpy } as any);
const schemaCacheModule = await import("../../../stores/schemaCacheStore");
vi.mocked(schemaCacheModule.useSchemaCacheStore.getState).mockReturnValue({ refreshSchema: refreshSpy } as any);
await renderApp();
await act(async () => {
window.dispatchEvent(new CustomEvent("menu-action", { detail: "refresh-schema" }));
Expand Down
4 changes: 2 additions & 2 deletions src/components/layout/__tests__/AppLayout.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ vi.mock("../../../hooks/useKeyboardShortcuts", () => ({
vi.mock("../../../hooks/useTheme", () => ({
useTheme: vi.fn(),
}));
vi.mock("../../../hooks/useSchemaCache", () => ({
useSchemaCache: {
vi.mock("../../../stores/schemaCacheStore", () => ({
useSchemaCacheStore: {
getState: vi.fn(() => ({ refreshSchema: vi.fn() })),
},
}));
Expand Down
Loading
Loading