awesome-sql-builder icon indicating copy to clipboard operation
awesome-sql-builder copied to clipboard

Escape identifiers automatically

Open sajithnechiparambil opened this issue 6 years ago • 3 comments

column names with '[columnName]'.

Example: SELECT [Id], [Name], [Age] FROM [Register]

sajithnechiparambil avatar Jun 20 '19 17:06 sajithnechiparambil

@sajithnechiparambil Do you mean escape characters according to the SQL provider? Such as PostGreSQL using " around names?

cdroulers avatar Jun 20 '19 17:06 cdroulers

Yes

sajithnechiparambil avatar Jul 09 '19 05:07 sajithnechiparambil

@sajithnechiparambil You're welcome to start a PR for this, I don't have any time to dedicate to this project these days and this is a big undertaking as well.

The columns could be easy, but this project was meant as a quick helper, for from a full SQL parser, which would be required to properly support this since the columns, order by clauses and where clauses, even from clauses would need to be parsed to properly escape them.

The basic example uses SqlStatements.Select(new[] { "u.ID", "u.Name", "u.EmailAddress" }) which would need to split on . and escape each part, same in WHERE clauses.

If I end up working on it some time, I'll try to get it done, but otherwise, I'll simply wait for a PR!

cdroulers avatar Jul 09 '19 13:07 cdroulers