( searchPath?: string, database?: string | null, schemas?: Schema[], )
| 12 | import { getSchemaNameFromSearchPath } from "~/api/materialize/useSchemas"; |
| 13 | |
| 14 | export function getSelectedSchemaOption( |
| 15 | searchPath?: string, |
| 16 | database?: string | null, |
| 17 | schemas?: Schema[], |
| 18 | ) { |
| 19 | const schemaName = getSchemaNameFromSearchPath(searchPath, schemas); |
| 20 | |
| 21 | if (!schemaName || !schemas || !database) { |
| 22 | return null; |
| 23 | } |
| 24 | |
| 25 | const doesSchemaExist = schemas.some( |
| 26 | ({ databaseName, name }) => |
| 27 | databaseName === database && name === schemaName, |
| 28 | ); |
| 29 | |
| 30 | if (!doesSchemaExist) { |
| 31 | return null; |
| 32 | } |
| 33 | |
| 34 | return { |
| 35 | id: createNamespace(database, schemaName), |
| 36 | name: schemaName, |
| 37 | databaseName: database ?? "", |
| 38 | }; |
| 39 | } |
no test coverage detected