Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ exports.encode = function encode (value) {
return '"' + exports.escape(value) + '"';
}
else if (value instanceof Date) {
return 'date("' + getOrientDbUTCDate(value) + '", "yyyy-MM-dd HH:mm:ss", "UTC")';
return 'date("' + getOrientDbUTCDate(value) + '", "yyyy-MM-dd HH:mm:ss.SSS", "UTC")';
}
else if (value instanceof RID) {
return value.toString();
Expand Down Expand Up @@ -314,8 +314,9 @@ function getOrientDbUTCDate(date){
var HH = pad(date.getUTCHours(), 2);
var mm = pad(date.getUTCMinutes(), 2);
var ss = pad(date.getUTCSeconds(), 2);
var SSS = pad(date.getUTCMilliseconds(), 3);

return yyyy + '-' + MM + '-' + dd + ' ' + HH + ':' + mm + ':' + ss;
return yyyy + '-' + MM + '-' + dd + ' ' + HH + ':' + mm + ':' + ss + '.' + SSS;
}

function pad (number, size){
Expand Down
4 changes: 2 additions & 2 deletions test/core/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ describe('utils.prepare', function () {
text.should.equal('SELECT * FROM OUser WHERE foo = "\\/// TE /// ST \\\\\\\\\\\\"');
});
it("should prepare SQL statements with date parameters", function () {
var date = new Date(Date.UTC(2015, 0, 5, 22, 7, 5));
utils.prepare("select from index:foo where date = :date", {date: date}).should.equal("select from index:foo where date = date(\"2015-01-05 22:07:05\", \"yyyy-MM-dd HH:mm:ss\", \"UTC\")");
var date = new Date(Date.UTC(2015, 0, 5, 22, 7, 5, 435));
utils.prepare("select from index:foo where date = :date", {date: date}).should.equal("select from index:foo where date = date(\"2015-01-05 22:07:05.435\", \"yyyy-MM-dd HH:mm:ss.SSS\", \"UTC\")");
});
});

Expand Down