Issue Details (XML | Word | Printable)

Key: NUCRDBMS-218
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Andy Jefferson
Reporter: Karl M. Davis
Votes: 0
Watchers: 0
Operations

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

TemporalLiteral does not quote non-property Timestamp or Date values

Created: 02/Jul/09 08:17 PM   Updated: 11/Sep/09 08:41 AM   Resolved: 18/Jul/09 03:04 PM
Component/s: Queries
Affects Version/s: 1.1.4
Fix Version/s: 1.1.5, 2.0.0.m1

File Attachments: 1. Text File TemporalLiteral-quoting.patch (0.6 kB)

Environment: OpenJDK 6, 32 bit Ubuntu Linux, HSQL

Forum Thread URL: http://www.jpox.org/servlet/forum/viewthread_thread,5659_lastpage,yes#30696
Datastore: HSQL
Severity: Development


 Description  « Hide
The org.datanucleus.store.rdbms.sql.expression.TemporalLiteral class does not quote non-property Date (or Timestamp) values when writing them out to SQLText. This can cause queries to fail as these values contains space(s).

The error I've received is "java.sql.SQLException: Unexpected token...", which is listed in full in the referenced forum thread. Specifically, I've seen this occur when trying to delete an instance of a class that:
 * uses application ID
 * has more than one primary key field (and thus an Object ID class)
 * is a concrete subclass (using InheritanceStrategy.SUPERCLASS_TABLE) of an abstract base class (using InheritanceStrategy.NEW_TABLE and DiscriminatorStrategy.CLASS_NAME)

Before deleting the instance, it issues a query based on the instance's ID, which fails with the previously-mentioned exception.

It's been a long time since I've done any SQL by hand, but I believe this problem would be resolved by wrapping the Date/Timestamp values in single quotes. I will attach a patch that addresses that.

Sort Order: Ascending order - Click to sort in descending order
Karl M. Davis added a comment - 02/Jul/09 08:19 PM
This patch is against the store.rdbms trunk project. It addresses a problem that seems to have been introduced in r5847 (http://datanucleus.svn.sourceforge.net/viewvc/datanucleus?view=rev&revision=5847).

Andy Jefferson added a comment - 03/Jul/09 08:03 AM
Thx for the patch, but a testcase would be nice too. That way you don't have any risk of issues being introduced.

BTW This was not "introduced" by any revision of this file. The whole SQL generation was changed in DN 1.1 and as you can see from that file there is a TODO above that line that hasn't been finished.

Andy Jefferson added a comment - 07/Jul/09 08:37 AM
Testcase ?

Karl M. Davis added a comment - 07/Jul/09 06:49 PM
I probably won't have time to put one together for a couple of days, though I'll definitely try to get you one by the end of this week.

I'm not too familiar with the test projects, unfortunately. Which test project would such a test case belong in? Would the model objects needed for the test go into a different project?

Andy Jefferson added a comment - 07/Jul/09 08:14 PM
test.jdo.general is for general JDO Tests.
test.samples is for samples if they are general enough for use in other suites.
test.jdo.general is for samples if they are not general enough for use in other suites.

Andy Jefferson added a comment - 18/Jul/09 03:04 PM
Closing since this project has to move forward and we have to have releases. I expect the testcases to arrive when you have time; attach them here