SQL : It is not possible to use an SQLUpdateClause which sets columns to expressions

Bug #650617 reported by Luis Fernando Planella Gonzalez
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Querydsl
Fix Released
Medium
Unassigned

Bug Description

Currently, the update clause only have a .set(Path<T>, T), but with this, it is not possible to do things like "update t set a = a + 1"
I think we would need another method like .set(Path<T>, Expression<T>).
Maybe this should be supported in inserts as well (defined on the StoreClause). Maybe custom expressions which invokes db functions would work (like insert into x values (current_timestamp())).

Tags: sql
tags: added: sql
summary: - It is not possible to use an SQLUpdateClause which sets columns to
+ SQL : It is not possible to use an SQLUpdateClause which sets columns to
expressions
Revision history for this message
Timo Westkämper (timo-westkamper) wrote :

I implemented that change in SVN trunk, but there is now the problem that set(someStringPath, null) calls are ambiguous and the compiler complains.

This can be fixed like this though :

set(someStringPath, (String)null)

Maybe an additional setNull(Path<?> path) could work. What do you think?

Changed in querydsl:
status: New → In Progress
Changed in querydsl:
importance: Undecided → Medium
Revision history for this message
Luis Fernando Planella Gonzalez (luisfpg) wrote :

For me, both solutions would be fine: either having an extra setNull(path) or having a method with a different name, like setExpression(path, expression)

Revision history for this message
Timo Westkämper (timo-westkamper) wrote :

Fixed in SVN trunk :

set(Path<T>,T)

set(Path<T>, Expression<? extends T>)

setNull(Path<T>)

Changed in querydsl:
status: In Progress → Fix Committed
Revision history for this message
Timo Westkämper (timo-westkamper) wrote :

Released in 2.0.1

Changed in querydsl:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.