#1 2016-09-29 05:15:34

sanyin
Member
Registered: 2014-11-08
Posts: 3

Return value if some field does not exist

I have MongoDB collection that contains documents where some fields are sometimes non existing. In that case I want to get a null value.
Using "ToDataSet" to show the result in the datagrid, there is an exception raised (IdemPropNameU).

Also, BSON (synMongoDB) function has a bug, an infinite loop if you specify invalid JSON string e.g. "{something".

Offline

#2 2016-09-29 05:58:29

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

Re: Return value if some field does not exist

Could you please be more specific about the issues?

Offline

#3 2016-09-29 06:15:15

sanyin
Member
Registered: 2014-11-08
Posts: 3

Re: Return value if some field does not exist

I have a collection with 10-12 fields. One document has only 1 field (_id). In this case, an error occurs when using DataSet that I got from ToDataset function (SynVirtualDataSet). (I use it in the DBGrid)

Exception:
00b40373 +00b Project1.exe SynCommons              23440  +5 IdemPropNameU
00b7241c +0dc Project1.exe SynVirtualDataSet         838  +8 TDocVariantArrayDataSet.GetRowFieldData
00b71601 +04d Project1.exe SynVirtualDataSet         414  +4 TSynVirtualDataSet.GetFieldData
006c16a7 +027 Project1.exe Data.DB                           TDataSet.GetFieldData
006afb06 +062 Project1.exe Data.DB                           TField.GetData
006afdf9 +01d Project1.exe Data.DB                           TField.GetIsNull

Offline

#4 2016-09-29 17:40:21

sanyin
Member
Registered: 2014-11-08
Posts: 3

Re: Return value if some field does not exist

Ok, error occurs when some document has different field names than previous.

{
_id:"1",
name:"bob",
age:33
}
{
_id:"2",
name:"somename",
age:31
}

{
_id:"3",
status:"X",
somedata:"ABC"
}

TFields "status" and "somedata" are not generated in tdataset?

Offline

#5 2017-05-02 15:35:30

joananjr
Member
From: Brasil
Registered: 2017-04-24
Posts: 8

Re: Return value if some field does not exist

That´s appear de same pronblem by other post with title invalid Date and time.

Offline

#6 2017-07-25 19:22:13

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

Re: Return value if some field does not exist

Please try https://synopse.info/fossil/info/d171280064

I've reverted to the previous version, which was reported to work - but for EMartin...

Offline

Board footer

Powered by FluxBB