sql-language-server icon indicating copy to clipboard operation
sql-language-server copied to clipboard

Support Node10

Open krassowski opened this issue 5 years ago • 2 comments

When being used with sqlite3. Some diagnostics do work (Expected "--", "/*", "FROM", "GROUP", "LIMIT", "ORDER", "UNION", "WHERE", [ \t\n\r], or end of input but "X" found.) but most frequently it just throws this error.

TypeError: diagnostics.concat(...).flat is not a function
    at rules.forEach (/home/krassowski/jupyterlab-lsp/node_modules/sqlint/dist/src/rules/index.js:68:60)
    at Array.forEach (<anonymous>)
    at apply (/home/krassowski/jupyterlab-lsp/node_modules/sqlint/dist/src/rules/index.js:46:11)
    at walk (/home/krassowski/jupyterlab-lsp/node_modules/sqlint/dist/src/rules/index.js:77:38)
    at Object.values.forEach (/home/krassowski/jupyterlab-lsp/node_modules/sqlint/dist/src/rules/index.js:79:23)
    at Array.forEach (<anonymous>)
    at walk (/home/krassowski/jupyterlab-lsp/node_modules/sqlint/dist/src/rules/index.js:78:25)
    at Object.execute (/home/krassowski/jupyterlab-lsp/node_modules/sqlint/dist/src/rules/index.js:32:12)
    at Object.lint (/home/krassowski/jupyterlab-lsp/node_modules/sqlint/dist/src/cli/lint.js:52:53)
    at doLint (/home/krassowski/jupyterlab-lsp/node_modules/sql-language-server/dist/src/createDiagnostics.js:16:40)

This happens at:

diagnostics = diagnostics.concat(_diagnostics).flat();

The example _diagnostics content is:

[ { location: { start: [Object], end: [Object] },
    message: 'A linebreak is required after SELECT keyword',
    errorLevel: 2,
    fix: [ [Object], [Object] ],
    rulename: 'linebreak-after-clause-keyword' } ]

The diagnostics is just an empty array: [].

[].concat([{ message: 'A linebreak is required after SELECT keyword'}])

results in:

[{ message: 'A linebreak is required after SELECT keyword'}]

which does not have the flat() method in the node 10.

So the only problem is that the required runtime it Node 11+, but it is not specified in readme I guess... Or maybe the concat().flat() could be replaced with push() and spread operator?

krassowski avatar Aug 29 '20 11:08 krassowski

@krassowski Hi, thank you for your report. I'll have a plan to deal with node 10.

joe-re avatar Aug 30 '20 22:08 joe-re

It also happens with node 14.

otreblan avatar Sep 25 '20 23:09 otreblan