Can't convert microsoft sql server script to dbml
维护者通常 1 天内回复
@huydo862003 已经在做这个了。
开始于 2025年11月6日。
评估
这个 Issue 还没有评估数据。
描述
I try to use js module to convert sql script to dbml.
Here is my sql script
CREATE TABLE dbo.hello (
id int IDENTITY(1,1) NOT NULL,
created_at datetime2(3) DEFAULT getdate() NOT NULL,
updated_at datetime2(3) DEFAULT getdate() NOT NULL,
deleted_at datetime2(3) NULL,
[key] nvarchar(225) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[value] int NOT NULL,
[w_id] int NOT NULL,
CONSTRAINT PK_8a11c3956fec7db6df1a0244e5f PRIMARY KEY (id)
);
CREATE UNIQUE NONCLUSTERED INDEX UQ_393c557e09ac67c724f8ec7334f ON dbo.hello ([key]);
CREATE UNIQUE NONCLUSTERED INDEX REL_4a6194b005c383df6539faa3f3 ON dbo.hello ( w_id ASC )
WHERE ([w_id] IS NOT NULL)
WITH ( PAD_INDEX = OFF ,FILLFACTOR = 100 ,SORT_IN_TEMPDB = OFF , IGNORE_DUP_KEY = OFF , STATISTICS_NORECOMPUTE = OFF , ONLINE = OFF , ALLOW_ROW_LOCKS = ON , ALLOW_PAGE_LOCKS = ON )
ON [PRIMARY ] ;
Here is my js script
const ddl = fs.readFileSync('./dbdocs/database.ddl', 'utf-8')
fs.writeFileSync('./dbdocs/database.dbml', importer.import(ddl, 'mssql'))
And I got an error message:
Error:
-- PARSING FAILED --------------------------------------------------
11 | CREATE UNIQUE NONCLUSTERED INDEX UQ_393c557e09ac67c724f8ec7334f ON dbo.hello ([key]);
12 | CREATE UNIQUE NONCLUSTERED INDEX REL_4a6194b005c383df6539faa3f3 ON dbo.hello ( w_id ASC )
> 13 | WHERE ([w_id] IS NOT NULL)
| ^
14 | WITH ( PAD_INDEX = OFF ,FILLFACTOR = 100 ,SORT_IN_TEMPDB = OFF , IGNORE_DUP_KEY = OFF , STATISTICS_NORECOMPUTE = OFF , ONLINE = OFF , ALLOW_ROW_LOCKS = ON , ALLOW_PAGE_LOCKS = ON )
15 | ON [PRIMARY ] ;
Expected one of the following:
comments, identifier, whitespaces
at Parsimmon._.tryParse (/Users/eugene/code/sto/sto-dapp/node_modules/parsimmon/src/parsimmon.js:928:15)
at Parsimmon.mssqlParser.parseWithPegError (/Users/eugene/code/sto/sto-dapp/node_modules/@dbml/core/lib/parse/mssql/index.js:7:24)
at Function.parseMSSQLToJSON (/Users/eugene/code/sto/sto-dapp/node_modules/@dbml/core/lib/parse/Parser.js:64:38)
at Function.parse (/Users/eugene/code/sto/sto-dapp/node_modules/@dbml/core/lib/parse/Parser.js:89:32)
at Object._import [as import] (/Users/eugene/code/sto/sto-dapp/node_modules/@dbml/core/lib/import/index.js:15:37)
at Object.<anonymous> (/Users/eugene/code/sto/sto-dapp/dbdocs/convert.ts:6:59)
at Module._compile (node:internal/modules/cjs/loader:1105:14)
at Module.m._compile (/Users/eugene/code/sto/sto-dapp/node_modules/ts-node/src/index.ts:1455:23)
at Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
at Object.require.extensions.<computed> [as .ts] (/Users/eugene/code/sto/sto-dapp/node_modules/ts-node/src/index.ts:1458:12) {
type: 'ParsimmonError',
result: {
status: false,
index: { offset: 557, line: 13, column: 9 },
expected: [ 'comments', 'identifier', 'whitespaces' ]
}
}
{
name: 'SyntaxError',
location: { start: { offset: 557, line: 13, column: 9 } },
found: '(',
message: 'Expected comments, identifier, or whitespaces but "(" found.'
}
I have tried to run this sql script on sql server, and it can success create table and index
- 主要语言
- JavaScript
- 星标
- 3.7k
- 派生
- 233
- 平均合并
- 2 天 4 小时
- 30 天内合并 PR
- 23
环境准备
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
holistics/dbml 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
@dbml/core 12.0.0 Postgres importer: timestamptz becomes timestamp, schema-qualified type doubled, Ref with ?<? rejected by parser可能已有人在做 @zzoraemon043 于 2 天前认领。 未关闭
难度 3/5 1-2 天 新手友好度 68/100
维护者通常 1 天内回复
-
难度 5/5 一周以上 新手友好度 38/100
维护者通常 1 天内回复
-
难度 3/5 1-2 天 新手友好度 48/100
维护者通常 1 天内回复
-
enhancement
难度 5/5 一周以上 新手友好度 35/100
holistics/dbml#868 · 1 条评论 · 1 个 reaction ·
维护者通常 1 天内回复
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
-
bug
难度 2/5 1-3 小时 新手友好度 68/100
mailcow/mailcow-dockerized#7677 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
gcivil-nyu-org/team5-mon-fall26#145 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 82/100
-
needs discussion
难度 2/5 1-3 小时 新手友好度 78/100
openfga/openfga.dev#1436 · 1 条评论 ·
维护者通常 2 天内回复