Can't compare a Date object to a Date column in a Select
I have a query that selects some data from a table, including a column that is a DATE datatype. When I then select from another table, using that value as a bind parameter, I get no results (and should - joining this same data in a query works).
//some pseudo code results = connection.execute("select mydate from mytable where somecondition = 'blah'", [], {outFormat: oracle.OBJECT}, function(err, results){ results.rows.forEach(function(row){ connection.execute("select name, location from myothertable where thedate = :dateparam", {dateparam: row.rundate}, {outFormat: oracle.OBJECT}, function(detailerr, detailresults) { console.dir(detail_results); }); }); });
My understanding is that DATE column values are converted to OCIDateTime. Does that conversion effect the ability to compare the result to a DATE column?
I tried switch to to_char for the comparison, but the conversion to the local timezone breaks it (dates are not stored with timezone information)
Is there a way to use the javascript Date the the driver returns to bind against a DATE column in a select statement?
I found a work around (about as soon as I posted this) :).
If i trunc the comparison it will work. So this: select name, location from myothertable where thedate = :dateparam becomes select name, location from myothertable where thedate = trunc(:dateparam)
Still seems that I should not have to do that.
I'm going to mark this as a bug, but really it needs more detailed analysis which will happen when we review date handling. It is common to need to truncate dates in Oracle queries to be able to do exact matches.
@lstroud this was an interesting problem. We have fixed it in node-oracledb 1.0. Try again.