Open alekbarszczewski opened 10 years ago
I think you want the ignorePeriodsForFieldNameQuotes
option, see http://hiddentao.github.io/squel/#autoquotes
alert(
squel.select({ autoQuoteTableNames: true, autoQuoteFieldNames: true })
.from("students", "s")
.field("s.name", "Student name", { ignorePeriodsForFieldNameQuotes: true })
);
/* SELECT `s.name` AS "Student name" FROM `students` `s` */
Not exactly. When using ignorePeriodsForFieldNameQuotes
whole field name is quoted regardless of periods presence. What I need is "User.Comment"."content"
. Anyway I just turned off autoQuoteFieldNames
and I am quoting field names manually.
Ah I see. Yeah, that's not supported out of the box as squel doesn't inherently understand the field name structure.
This could perhaps be fixed by having Squel assume that the last period (.) separates the field name from the db-table specifier. Right now it just tokenizes around every period (.) and adds quotes. What do people think?
I think there has to be a more flexible solution. I am working on a flavour/port for SAP HANA Database, and I'm struggling with a similar problem regarding table aliases in front of field names where I would need something like "t0"."type.field"
.
Sounds like the user needs to be able to specify a custom function for handling the quotation of field names.
Sounds like the user needs to be able to specify a custom function for handling the quotation of field names.
Code above produces:
What I want is to get: (
"User.Comment"."content" AS...
instead of"User"."Comment"."content"
)I tried this:
But it just generates
""User"."Comment""."content" AS...
Maybe Squel should for example check if there already exist any quotation character (
"
in this example) in field name string and if it does then don't auto quote?Maybe there is other option to make it work as I want?