Project

General

Profile

Actions

Support #8050

closed

Wt::Dbo - where changes clause

Added by Torsten Schulz about 3 years ago. Updated almost 3 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
Start date:
02/10/2021
Due date:
% Done:

0%

Estimated time:

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.

Actions #1

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.

Actions #2

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.

Actions #3

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.

Actions #4

Updated by Roel Standaert almost 3 years ago

  • Status changed from New to Closed
Actions

Also available in: Atom PDF