I'm using RJDBC to access a SQL Server database. Everything works pretty well except for one thing (that keeps it from working at all). dbplyr is defaulting to quoting table aliases in the resulting SQL like this:
SELECT
top 5 *
FROM
mydb.myschema.mytable "mt"
join mydb.myschema.myothertable "mot" on "mt".key = "mot".key
My SQL Server thinks that's a really bad idea and desperately wants me to put table aliases in square brackets:
SELECT
top 5 *
FROM
mydb.myschema.mytable [mt]
join mydb.myschema.myothertable [mot] on [mt].key = [mot].key
I can see from the documentation that DBI:: dbQuoteIdentifier() is involved in this process, but I can't figure out how to tell it to use square brackets.
It feels like there should be a way to tell DBI that it should be using SQL Server norms here... but I can't figure out how. Or even just to override the table alias quoting.
RJDBC support - Even though it is not considered an issue, we have found a workaround. The approach is to point the current JDBC connection to the MS SQL translation inside dbplyr :