Project

General

Profile

Actions

Bug #1433

open

Dbo: crash when sort QueryModel for query, including orderBy with bound values

Added by Boris Nagaev over 11 years ago. Updated over 11 years ago.

Status:
Feedback
Priority:
Normal
Assignee:
-
Target version:
-
Start date:
09/10/2012
Due date:
% Done:

0%

Estimated time:

Description

Hello!

Pseudocode bellow is what I am trying to do.

Query query;
...
query.orderBy("id = ? desc").bind(special_object);
QueryModel model;
model.setQuery(query);
model.sort(another column);
// crash "ERROR:  bind message supplies X parameters, but prepared statement "..." requires X-1

I think, if some part of query (for example, "orderBy") is replaced (or removed), then parameters bound to that part should be replaced (or removed) as well.

Actions #1

Updated by Koen Deforche over 11 years ago

  • Status changed from New to Feedback

Hey,

I'm not sure that will work in general (Wt Dbo does not attempt to parse queries to that level of understanding).

In this case, you should choose to let the query model handle the sorting, and remove it from the original query.

Regards,

koen

Actions #2

Updated by Boris Nagaev over 11 years ago

Hello!

Wt Dbo can memorize a 'parent' of each bound value. This would be particular WHERE or ORDER BY clause. This can be implemented, since order of bind's must be the same as order of corresponding .orderBy(), .where(), etc. When query model sorts the query, these bound values will be discarded as well as original ORDER BY (their parent).

For my particular case I have a workaround. This ticket was created to make behaviour of Wt::Dbo more predictable.

Actions #3

Updated by Koen Deforche over 11 years ago

Hey,

I think that I understand what you aim after: orderBy(...).bind(x) would tie 'x' to the orderBy() clause.

However, this is currently not an implied relation: .bind(x) can be called at any time in the query, before or after the orderBy() clause, including at the very end...

I do understand the possibility now, but I am not sure whether we should implement it (as it does complicate things).

Regards,

koen

Actions

Also available in: Atom PDF