Skip to content

The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:

Show empty schemas in transform target and table metadata (#68592)

Romeo Van Snick0b8c5cd5a39c
diff --git a/e2e/support/test_tables.js b/e2e/support/test_tables.js
index 7b51bb1d56a..53e7652ddad 100644
--- a/e2e/support/test_tables.js
+++ b/e2e/support/test_tables.js
@@ -288,6 +288,12 @@ export const many_schemas = async (dbClient) => {
return schemas;
};
+export const empty_schema = async (dbClient) => {
+ const schemaName = "empty_schema";
+ await dbClient.schema.createSchemaIfNotExists(schemaName);
+ return null;
+};
+
export const cached_table = async (dbClient) => {
const tableName = "cached_table";
diff --git a/e2e/test/scenarios/data-studio/transforms/reproductions.cy.spec.ts b/e2e/test/scenarios/data-studio/transforms/reproductions.cy.spec.ts
new file mode 100644
index 00000000000..505c908e087
--- /dev/null
+++ b/e2e/test/scenarios/data-studio/transforms/reproductions.cy.spec.ts
@@ -0,0 +1,38 @@
+const { H } = cy;
+import { WRITABLE_DB_ID } from "e2e/support/cypress_data";
+
+describe("issue #68378", () => {
+ beforeEach(() => {
+ H.restore("postgres-writable");
+ H.resetTestTable({ type: "postgres", table: "empty_schema" });
+ cy.signInAsAdmin();
+ H.activateToken("bleeding-edge");
+ cy.request("POST", `/api/database/${WRITABLE_DB_ID}/sync_schema`);
+ });
+
+ it("should show empty schema's when picking a target schema (metabase#68378)", () => {
+ visitTransformListPage();
+ cy.button("Create a transform").click();
+ H.popover().findByText("SQL query").click();
+ H.NativeEditor.type("SELECT 42", { allowFastSet: true });
+
+ cy.log("Save with empty_schema as target schema");
+ getQueryEditor().button("Save").click();
+
+ H.modal().within(() => {
+ cy.findByLabelText("Name").clear().type("SQL transform");
+ cy.findByLabelText("Schema").click();
+ });
+ H.popover().findByText("empty_schema").should("be.visible").click();
+
+ H.modal().button("Save").click();
+ });
+});
+
+function visitTransformListPage() {
+ return cy.visit("/data-studio/transforms");
+}
+
+function getQueryEditor() {
+ return cy.findByTestId("transform-query-editor");
+}
diff --git a/e2e/test/scenarios/data-studio/transforms.cy.spec.ts b/e2e/test/scenarios/data-studio/transforms/transforms.cy.spec.ts
similarity index 100%
rename from e2e/test/scenarios/data-studio/transforms.cy.spec.ts
rename to e2e/test/scenarios/data-studio/transforms/transforms.cy.spec.ts
diff --git a/enterprise/frontend/src/metabase-enterprise/transforms/pages/NewTransformPage/CreateTransformModal/CreateTransformModal.tsx b/enterprise/frontend/src/metabase-enterprise/transforms/pages/NewTransformPage/CreateTransformModal/CreateTransformModal.tsx
index 8f021113307..96989c74d8b 100644
--- a/enterprise/frontend/src/metabase-enterprise/transforms/pages/NewTransformPage/CreateTransformModal/CreateTransformModal.tsx
+++ b/enterprise/frontend/src/metabase-enterprise/transforms/pages/NewTransformPage/CreateTransformModal/CreateTransformModal.tsx
@@ -6,7 +6,7 @@ import { hasFeature } from "metabase/admin/databases/utils";
import {
skipToken,
useGetDatabaseQuery,
- useListDatabaseSchemasQuery,
+ useListSyncableDatabaseSchemasQuery,
} from "metabase/api";
import FormCollectionPicker from "metabase/collections/containers/FormCollectionPicker";
import { LoadingAndErrorWrapper } from "metabase/common/components/LoadingAndErrorWrapper";
@@ -61,9 +61,7 @@ export function CreateTransformModal({
data: schemas = [],
isLoading: isSchemasLoading,
error: schemasError,
- } = useListDatabaseSchemasQuery(
- databaseId ? { id: databaseId, include_hidden: true } : skipToken,
- );
+ } = useListSyncableDatabaseSchemasQuery(databaseId ?? skipToken);
const isLoading = isDatabaseLoading || isSchemasLoading;
const error = databaseError ?? schemasError;