storebrand / target-mssql

Singer.io compatible Target for SQL Server. Created with the Meltano SDK.
Apache License 2.0
3 stars 15 forks source link

Column name as Keyword #37

Open miko866 opened 4 months ago

miko866 commented 4 months ago

Hi, The MSSQL DB has a column name which is called index, which is of course a keyword. Error is pymssql._mssql.mssqldatabaseexception Incorrect syntax near ‘index’ . If this is intended as a part of a table hint, A WITH keyword and parenthesis are now required ... I use tap-mssql --variant buzzcutnorman as the extractor and it works as is expected.

Full Error message -> sqlalchemy.exc.OperationalError: (pymssql.exceptions.OperationalError) (1018, b”Incorrect syntax near ‘index’. If this is intended as a part of a table hint, A WITH keyword and parenthesis are now required. See See SQL Server Books Online for proper synatx.DB-Lib error message 20018, serverity 15:\nGeneral SQL Server error: Check messages from the SQL Server\n”) I think the problem is because the index has single quotation. The T-SQL syntax should be [index] for that case.

How I could sort this out, please?

radbrt commented 3 months ago

Hi, you are entirely correct @miko866 this target does not properly bracket column names. The best fix for you is probably to look at one of the 12 forks, several of which has implemented this fix (none of them have made a PR back here). I can probably help out figuring which of the forks are best for that purpose, or you might ask in the slack.

miko866 commented 3 months ago

Hi @radbrt, I'd be grateful if you could help me find the fork, I've already asked in slack about the problem but no answer.

radbrt commented 3 months ago

Sorry for the late reply @miko866. The fork I was thinking of was https://github.com/FXTransparency/target-mssql, they accidentally submitted (and deleted) a PR to this repo with what looked like the necessary changes for correctly bracketing column names.

If you are feeling adventurous, you can also try my old attempt at bracketing, which lives in its own branch of my own fork: https://github.com/radbrt/target-mssql/tree/orig-colnames

miko866 commented 2 months ago

Hi @radbrt, thank for your answer. I will take a look at that.