Can't convert microsoft sql server script to dbml

Aperta
#263 0 commenti 2 reazioni 1 assegnatario Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@huydo862003 ci sta già lavorando.

Dal 6/11/2025.

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

bug

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

Lingua principale
JavaScript
Stelle
3.7k
Fork
233
Merge medio
2g 4h
PR unite (30g)
23

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di holistics/dbml

Tutte le issue di holistics/dbml

Issue simili

Altre issue su JavaScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.