MCPcopy Create free account
hub / github.com/antvis/AVA / exposedSQL

Function exposedSQL

src/remote/sqlserver/schema.ts:8–21  ·  view source on GitHub ↗
(schema?: string)

Source from the content-addressed store, hash-verified

6import type { Schema } from '../../types';
7
8function exposedSQL(schema?: string): string {
9 const filter = schema === undefined ? '' : `AND s.name = N${sqlStringLiteral(schema)}`;
10 return `SELECT t.object_id, s.name AS schema_name, t.name AS source_table,
11 t.object_type, QUOTENAME(s.name) + N'.' + QUOTENAME(t.name) AS model_name
12FROM (
13 SELECT object_id, schema_id, name, is_ms_shipped, 'U' AS object_type FROM sys.tables
14 UNION ALL
15 SELECT object_id, schema_id, name, is_ms_shipped, 'V' AS object_type FROM sys.views
16) AS t
17JOIN sys.schemas AS s ON s.schema_id = t.schema_id
18WHERE t.is_ms_shipped = 0
19 ${filter}
20 AND HAS_PERMS_BY_NAME(QUOTENAME(s.name) + N'.' + QUOTENAME(t.name), 'OBJECT', 'SELECT') = 1`;
21}
22
23const tablesSQL = `SELECT 'table' AS kind, e.model_name AS table_name, e.source_table,
24 (SELECT DB_NAME() AS catalog, e.schema_name AS [schema]

Callers 1

getSQLServerSchemaFunction · 0.70

Calls 1

sqlStringLiteralFunction · 0.90

Tested by

no test coverage detected