Skip to main content
Glama

Prisma MCP Server

Official
by prisma
Apache 2.0
4
44,192
  • Linux
  • Apple
extractSqliteSources.test.ts3.11 kB
import path from 'node:path' import { expect, test } from 'vitest' import { extractSqliteSources } from './extractSqliteSources' import { serializeDatasources } from './serializeDatasources' expect.addSnapshotSerializer({ test: (val) => path.sep === '\\' && typeof val === 'string' && val.includes('\\'), serialize(val, config, indentation, depth, refs, printer) { const newVal = val.replaceAll('\\', '/') return printer(newVal, config, indentation, depth, refs) }, }) test('ignore comments', () => { const datamodel = `datasource db { provider = "sqlite" // url = "file:another/wrong/folder/dev.db" url = "file:my/folder/dev.db" } generator client { provider = "prisma-client-js" output = "@prisma/client" transpile = false } model User { id String @id @default(uuid()) email String @unique name String? posts Post[] } model Post { id String @id @default(uuid()) createdAt DateTime @default(now()) updatedAt DateTime @updatedAt randomDate DateTime published Boolean title String content String? author User? } /// Role num comment enum Role { USER ADMIN }` const result = extractSqliteSources(datamodel, '/cwd', '/outputdir') expect(result).toMatchInlineSnapshot(` [ { "name": "db", "url": "../cwd/my/folder/dev.db", }, ] `) let serializedResult = serializeDatasources(result) // TODO: Windows: fixup to work around a bug in jestSnapshotSerializer if (process.platform === 'win32') { serializedResult = serializedResult.replace(/\\\\/g, '/') } expect(serializedResult).toMatchInlineSnapshot(` "[ { "name": "db", "url": "../cwd/my/folder/dev.db" } ]" `) }) test('basic happy path', () => { const datamodel = `datasource db { provider = "sqlite" url = "file:my/folder/dev.db" } generator client { provider = "prisma-client-js" output = "@prisma/client" transpile = false } model User { id String @id @default(uuid()) email String @unique name String? posts Post[] } model Post { id String @id @default(uuid()) createdAt DateTime @default(now()) updatedAt DateTime @updatedAt randomDate DateTime published Boolean title String content String? author User? } /// Role num comment enum Role { USER ADMIN }` const result = extractSqliteSources(datamodel, '/cwd', '/outputdir') expect(result).toMatchInlineSnapshot(` [ { "name": "db", "url": "../cwd/my/folder/dev.db", }, ] `) let serializedResult = serializeDatasources(result) // TODO: Windows: fixup to work around a bug in jestSnapshotSerializer if (process.platform === 'win32') { serializedResult = serializedResult.replace(/\\\\/g, '/') } expect(serializedResult).toMatchInlineSnapshot(` "[ { "name": "db", "url": "../cwd/my/folder/dev.db" } ]" `) })

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/prisma/prisma'

If you have feedback or need assistance with the MCP directory API, please join our Discord server