Support #8050
closedWt::Dbo - where changes clause
0%
Description
Following example is generating a different query then expected
session.query("select ""id"" from ""tbl"").where("""name"" = ?").bind("test")
Expected query:
select "id" from "tbl" where "name" = ?
Generated query:
select "id" from "tbl" where name = ?
So in where clause, the quotes get lost.
Updated by Roel Standaert about 3 years ago
- Tracker changed from Bug to Support
""
is not how you escape double quotes in C++. You've just got separate string literals "select "
, "id"
, " from "
, "tbl"
that are being concatenated to "select id from tbl"
, and ""
, "name"
and " = ?"
being concatenated to "name = ?"
.
You can escape the double quotes with a backslash, or use a raw string literal.
Updated by Torsten Schulz about 3 years ago
Roel Standaert wrote in #note-1:
You can escape the double quotes with a backslash, or use a raw string literal.
Thank you for the answer, and you're of course right that double quotes not officialy. But some compilers accept it.
But even with .where("\"name\" = ?") it is the same result. I just get where name = ?
Maybe you'll say, it doesn't matter. But for DB2 it does. In DB2 a where name='' will be changed to where NAME='', what's not working. But a where "name"='' is working.
Updated by Torsten Schulz almost 3 years ago
Seems to work with 4.5.0 - or I made I change in Wt I can't remember. But for me the ticket can be closed.