[CSHARP-52] bugs in generated JavaScript Created: 21/Jul/10  Updated: 22/Jul/10  Resolved: 21/Jul/10

Status: Closed
Project: C# Driver
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Timofei Mironov Assignee: Craig Wilson
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

VS2008, .NET 3.5



 Description   

I was debugging one of my code and found interesting output for me.

At the MongoQueryObject.Query there was text :

{ "$where":

{ "$code": "(((this.ServiceKey === 4c46d7657c1a601774000002) && (this.ResourceKey === 4c46d7657c1a601774000003)) && ((((this.Start >= 01/01/2000 10:00:00) && (this.Start < 01/01/2000 18:00:00)) || ((this.End > 01/01/2000 10:00:00) && (this.End <= 01/01/2000 18:00:00))) || ((this.Start < 01/01/2000 10:00:00) && (this.End > 01/01/2000 18:00:00))))" }

}

As i understand from MongoDb docs after $where should be JavaScrip
code to run on server side.

Question 1: why it didn't translated into json notation to find
document ?
Answer: maybe because we have more then one condition per field

Question 2: if it is JavaScript code, why values don't have quotes
'4c46d7657c1a601774000002' and '01/01/2000 10:00:00'

Maybe better make like the following
this.End <= new Date(2000,1,1,18,0,0)

link: http://groups.google.com/group/mongodb-csharp/browse_thread/thread/b00e288d0ebce78



 Comments   
Comment by Timofei Mironov [ 22/Jul/10 ]

public static string SerializeForServerSide(object value)
{
...
--> sb.AppendFormat("new Date(

{0},{1},{2},{3},{4},{5},{6})", d.Year, d.Month, d.Date, d.Hour, d.Minute, d.Second, d.Millisecond);
....
}


to

sb.AppendFormat("new Date({0}

,

{1}

,

{2}

,

{3}

,

{4}

,

{5}

,

{6}

)", d.Year, d.Month, d.Day, d.Hour, d.Minute, d.Second, d.Millisecond);

Should be d.Day instead of d.Date.

Comment by Timofei Mironov [ 22/Jul/10 ]

Fix this code. from

Comment by Craig Wilson [ 21/Jul/10 ]

This is fixed in my fork: http://github.com/craiggwilson/mongodb-csharp

Generated at Wed Feb 07 21:35:40 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.