Issue Details (XML | Word | Printable)

Key: NUCRDBMS-842
Type: New Feature New Feature
Status: Open Open
Priority: Testcase Required Testcase Required
Assignee: Unassigned
Reporter: Sergey Shelukhin
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
DataNucleus Store RDBMS

add type conversion support for primitive types (such as SQL CAST(X as Y))

Created: 30/Jul/13 08:29 PM   Updated: 19/Nov/14 11:42 AM
Component/s: None
Affects Version/s: None
Fix Version/s: None


 Description  « Hide
It would be useful to be able to use expressions such as Integer.parse(string) (or string.toInt(), or (Integer)string; as well as from number to string) inside JDOQL queries. It is possible via plugin, but could be done better as core functionality with SQL and in-memory support.
Seems like String/NumericExpression would be relatively easy to extend for SQL via cast method for example, but I haven't looked at code in great detail, and not at all for in-memory processing when using non-SQL stores.
What do you think?
I might be able to make a patch if there's consensus on the approach (and time :().

Sort Order: Ascending order - Click to sort in descending order
Andy Jefferson added a comment - 31/Jul/13 04:21 PM
JDOQL reflects Java and since you can do something like that via a cast or via various methods then which way you choose to implement it is up to you. Obviously if doing it via a method then that method has to reflect a real Java method (of which Integer.parse(String) is not ... Integer.parseInt(String), or Integer.valueOf(String) are valid).

Number to String conversion is possible in JDOQL, like in Java by doing
"" + intField

non-RDBMS datastores in general don't have much flexibility in terms of in-datastore querying, so often just fallback to the in-memory handler, hence if providing support then do in-memory too. Just follow the docs
http://www.datanucleus.org/products/accessplatform_3_3/jdo/jdoql.html#methods
and attach your patch(es) here

Andy Jefferson added a comment - 19/Nov/14 11:42 AM
A test is always required to demonstrate anything. But then the raiser implied that they would be looking at adding this feature ...