#1 2014-09-16 02:32:32

bigheart
Member
Registered: 2014-08-01
Posts: 45

[mongoDB] When using FindDocs function, "doc.VType = 275" error occur

Hello!

I try to get the documents as "V1" value is greater than "6600" like below:

LColl := FDB.CollectionOrCreate[FMongoCollectionName];
SetLength(ADocs, LDocsCount);
LColl.FindDocs('{V1:{$gt, ?}}', ['6600'], ADocs);

but i've got error message as

"EBSONException : doc.VType = 275"

What's the problem?

Offline

#2 2014-09-16 08:53:47

bigheart
Member
Registered: 2014-08-01
Posts: 45

Re: [mongoDB] When using FindDocs function, "doc.VType = 275" error occur

Using Debug,  I can see that FindDocs function's argument "Projection" has 275 as VType in the TBSONVariant.FromBSONDocument().

And TMongoRequestQuery.Create()  -> BSONWriteParam() -> BSONWriteDoc() executed squentially.

In BSONWriteDoc(),     

if TVarData(doc).VType<>DocVariantType.VarType then
      raise EBSONException.CreateFmt('doc.VType=%d',[TVarData(doc).VType]) else ===> Exception eraise here

TVarData(doc).VType is 275,
DocVariantType.VarType is 274.

waht's the meaning of 274 or 275 ?

Offline

#3 2014-09-16 10:56:42

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,182
Website

Re: [mongoDB] When using FindDocs function, "doc.VType = 275" error occur

'{V1:{$gt, ?}}' is not valid JSON.

Try

'{V1:{$gt:?}}'

Offline

#4 2014-09-16 23:14:16

bigheart
Member
Registered: 2014-08-01
Posts: 45

Re: [mongoDB] When using FindDocs function, "doc.VType = 275" error occur

Thanks your advice.

I've tried as:

    LColl.FindDocs('{V1:{$gt:?}}', ['6600'], ADocs);

Same error is occured.

Also as:

    LColl.FindDocs('{V1:?}', ['6600'], ADocs, 'V1'); ==> projcetion parmeter is 'V1'

Same thing.

I think that the problem is not the JSON format but the projection parameter type.

When and How to determine DocVariantType.VarType to 274 ?

And Why TVarData(doc).VType is 275 as different to DocVariantType.VarType?

===============================================

According to the code of TMongoRequest.BSONWriteParam() in synMongoDB.pas,
projection parameter treated as BSONVariantType, but when TBSONVariantData(projection).VBlob is null then typecast as TDocVariantData.
And exception occured.

How to aviod this problem?

Last edited by bigheart (2014-09-17 02:46:44)

Offline

#5 2014-09-17 05:29:36

bigheart
Member
Registered: 2014-08-01
Posts: 45

Re: [mongoDB] When using FindDocs function, "doc.VType = 275" error occur

I've solved the problem partially.

LColl.FindDocs('{V1:?}', ['6600'], ADocs); ===> Exception occured that "EBSONException : doc.VType = 275"
LColl.FindDocs('{V1:?}', ['6600'], ADocs, 'V1'); ===> Same above
LColl.FindDocs('{V1:?}', ['6600'], ADocs, 'NULL'); ===> **Succeed**

I don't know why succeeded.

Offline

#6 2014-09-17 06:14:06

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,182
Website

Re: [mongoDB] When using FindDocs function, "doc.VType = 275" error occur

No problem on our side...
Did you get the latest source?

Offline

#7 2014-09-17 06:50:52

bigheart
Member
Registered: 2014-08-01
Posts: 45

Re: [mongoDB] When using FindDocs function, "doc.VType = 275" error occur

I had already mORMot ver 1.18.

But I have updated from mORMotNightlyBuild.zip just before, So the problem is solevd.

Build number should be displayed as part of filename in the download site, i think.

Also, "Synopse mORMot Framework SAD 1.18.pdf" file should be modified as below at Page 884:

FindDocs('{name:?,age:{$gt,?}}',['John',21],res); ===> FindDocs('{name:?,age:{$gt:?}}',['John',21],res, Null);

Anyway thanks for your efforts and sharing.

Last edited by bigheart (2014-09-17 06:51:46)

Offline

#8 2014-09-17 12:49:13

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,182
Website

Re: [mongoDB] When using FindDocs function, "doc.VType = 275" error occur

When you download the nightly build, you have the revision number part of the .zip, as root folder.
See e.g. today it is "mORMot_and_Open_Source_friends_2014-09-16_200937_a370968c84"

This a370968c84 is the current fossil commit - see http://synopse.info/fossil/timeline
With modern DVCS source control managers (like Fossil or Git), you do not have an incremental "revision" number, as with SVN.
You have a "hash" of the commit itself, e.g. "a370968c84" in our case.

I have fixed the doc.
Thanks for the feedback!

Offline

#9 2014-09-18 12:44:00

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,182
Website

Re: [mongoDB] When using FindDocs function, "doc.VType = 275" error occur

Update:
Since this hash should be confusing, SYNOPSE_FRAMEWORK_VERSION constant will now include a per-commit increasing number, e.g. 1.18.259 instead of plain 1.18 version (generated by SourceCodeRep tool into SynopseCommit.inc file), to specify the exact source state.
See http://synopse.info/fossil/info/2fca395ee48

It should help identifying on which source you are working.
Each commit will also include this number, within its description text, e.g. {259}, on both Fossil and Git repositories.

I hope it will reduce the number of issues post on this forum, just because the source used was out of date.

Offline

Board footer

Powered by FluxBB