dbml icon indicating copy to clipboard operation
dbml copied to clipboard

sql2dbml ERROR: You have a syntax error at line 1 column 1. Expected...

Open dsoverby1986 opened this issue 3 years ago • 8 comments

Just installed dbml.

Want to convert my scripted mssql db to dbml.

In SSMS, scripted all database tables to file. Saved file.

Executed:

sql2dbml <scripted db file name>.sql --mssql

Get the following error:

ERROR: You have a syntax error at "<filename>" line 1 column 1. Expected "ALTER", "COMMENT", "CREATE", "DROP", "INSERT", "RESET", "SELECT", "SET", "USE", end of input, or space but "�" found.

TYIA for any tips to get passed this error.

dsoverby1986 avatar Feb 15 '22 22:02 dsoverby1986

The --mssql option is not previously added to CLI modules. We've fixed this with the released 2.4.0 version. Maybe you should try it again.

TeaNguyen avatar Mar 14 '22 11:03 TeaNguyen

I am receiving the same error with version 2.4.0. Please let me know if I can provide any additional information.

joshuayoerger avatar Mar 22 '22 00:03 joshuayoerger

Hi, could you provide samples of the SQLs that receive this error so we can investigate more?

NQPhuc avatar Mar 22 '22 02:03 NQPhuc

It's because of ON UPDATE CURRENT_TIMESTAMP.. the parser doesn't understand it...

there are other issues open that are being ignored .... https://github.com/holistics/dbml/issues/141

ortonomy avatar Mar 25 '22 08:03 ortonomy

Since we haven't supported other encoding except for UTF-8, maybe you can convert the file's encoding to UTF-8 & try again.

TeaNguyen avatar Apr 12 '22 17:04 TeaNguyen

@TeaNguyen -- this maybe doesn't concern encoding... the sql2dbml fails on so many places -- it complains about triggers, it doesn't support ON UPDATE CURRENT_TIMESTAMP etc.

ortonomy avatar Jun 08 '22 08:06 ortonomy

CREATE TABLE IF NOT EXISTS schema1.Area ( areaId VARCHAR(45) NOT NULL, areaName VARCHAR(45) NULL DEFAULT NULL, themeId VARCHAR(45) NULL DEFAULT NULL, PRIMARY KEY (areaId), INDEX fk_Area_1_idx (themeId ASC) VISIBLE, CONSTRAINT fk_Area_1 FOREIGN KEY (themeId) REFERENCES coedb.Theme (themeId)) ENGINE = InnoDB DEFAULT CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci;

the sql is throwing error while converting it to dbml at the point "INDEX". The error is : Expected ")" or fields but "I" found.

ashokkumarideapoke avatar Nov 21 '22 07:11 ashokkumarideapoke

I tried to convert my following tables in SQLite3 and got the similar error message.

My table:

CREATE TABLE ticket(
  -- Do not change any column that begins with tkt_
  tkt_id INTEGER PRIMARY KEY,
  tkt_uuid TEXT UNIQUE,
  tkt_mtime DATE,
  tkt_ctime DATE,
  -- Add as many fields as required below this line
  type TEXT,
  status TEXT,
  subsystem TEXT,
  priority TEXT,
  severity TEXT,
  private_contact TEXT,
  resolution TEXT,
  title TEXT,
  comment TEXT,
  admin_id TEXT
);
CREATE TABLE ticketchng(
  -- Do not change any column that begins with tkt_
  tkt_id INTEGER REFERENCES ticket,
  tkt_rid INTEGER REFERENCES blob,
  tkt_mtime DATE,
  tkt_user TEXT,
  -- Add as many fields as required below this line
  login TEXT,
  username TEXT,
  mimetype TEXT,
  icomment TEXT
);
CREATE INDEX ticketchng_idx1 ON ticketchng(tkt_id, tkt_mtime);

The Error message:

2023-08-24T07:06:11.769Z
SyntaxError: You have a syntax error at "fossil-ticket.sql" line 1 column 1. Can't find table "null"."blob"
    at /Volumes/Chaka/swamp/servo/utileco/node.js/node_modules/@dbml/cli/lib/cli/utils.js:45:13
    at Array.forEach (<anonymous>)
    at generate (/Volumes/Chaka/swamp/servo/utileco/node.js/node_modules/@dbml/cli/lib/cli/utils.js:39:14)
    at importHandler (/Volumes/Chaka/swamp/servo/utileco/node.js/node_modules/@dbml/cli/lib/cli/import.js:25:27)
    at Object.sql2dbml (/Volumes/Chaka/swamp/servo/utileco/node.js/node_modules/@dbml/cli/lib/cli/index.js:27:23)
    at Object.<anonymous> (/Volumes/Chaka/swamp/servo/utileco/node.js/node_modules/@dbml/cli/bin/sql2dbml.js:4:19)
    at Module._compile (node:internal/modules/cjs/loader:1233:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1287:10)
    at Module.load (node:internal/modules/cjs/loader:1091:32)
    at Module._load (node:internal/modules/cjs/loader:938:12)

ROOT_ERROR:
Error: Can't find table "null"."blob"
    at Endpoint.error (/Volumes/Chaka/swamp/servo/utileco/node.js/node_modules/@dbml/core/lib/model_structure/element.js:55:13)
    at new Endpoint (/Volumes/Chaka/swamp/servo/utileco/node.js/node_modules/@dbml/core/lib/model_structure/endpoint.js:59:13)
    at /Volumes/Chaka/swamp/servo/utileco/node.js/node_modules/@dbml/core/lib/model_structure/ref.js:71:31
    at Array.forEach (<anonymous>)
    at Ref.processEndpoints (/Volumes/Chaka/swamp/servo/utileco/node.js/node_modules/@dbml/core/lib/model_structure/ref.js:70:20)
    at new Ref (/Volumes/Chaka/swamp/servo/utileco/node.js/node_modules/@dbml/core/lib/model_structure/ref.js:58:11)
    at /Volumes/Chaka/swamp/servo/utileco/node.js/node_modules/@dbml/core/lib/model_structure/database.js:133:28
    at Array.forEach (<anonymous>)
    at Database.processSchemaElements (/Volumes/Chaka/swamp/servo/utileco/node.js/node_modules/@dbml/core/lib/model_structure/database.js:107:16)
    at new Database (/Volumes/Chaka/swamp/servo/utileco/node.js/node_modules/@dbml/core/lib/model_structure/database.js:68:11)
{"start":{"line":1,"column":1}}

exaos avatar Aug 24 '23 07:08 exaos