#1 mORMot 2 » Strings not stored as they are if they look like ISO 8601 » 2023-07-20 13:39:29

Bjoern Henke
Replies: 1

The TBsonWriter writes strings as a double value if they look like an ISO 8601. When I get them back from the database, I don't get the original string.

Currently, the only option to fix this, seems to be to remove "Iso8601CheckAndDecode(value, valueLen, dt) or" from TBsonWriter.BsonWriteUtf8OrDecode.
The two "MAGIC" conditions should be fine but checking every string for ISO 8601 and forcing them into datetime can change the string unintentionally.

#2 Re: mORMot 1 » mORMot2: Loosing binary data somewhere in conversion » 2022-12-15 16:55:28

The code above is just an example to reproduce the problem.

I'm basically searching for a way to convert mongo JSON back to a variant. Mainly the opposite of VariantSaveMongoJson.

The best I found so far was the combination of Bson and BsonDocumentToDoc which seemed to be working except the loss of the binary data.

#3 Re: mORMot 1 » mORMot2: Loosing binary data somewhere in conversion » 2022-12-12 16:00:09

GetValueOrNull calls SetVariantByValue which then does TSynInvokeableVariantType.CopyByValue.
The variant type is DocVariantType (274) instead of BsonVariantType (275) needed by ToBlob.

I already tried GetVarData instead of GetValueOrNull but the result remains the same.

I couldn't yet find a way to convert a DocVariantType into a BsonVariantType and I'm wondering how TRestStorageMongoDB.RetrieveBlobFields accomplishes this.

#4 mORMot 1 » mORMot2: Loosing binary data somewhere in conversion » 2022-12-07 16:36:29

Bjoern Henke
Replies: 4

I've some binary data stored as RawByteString and convert it to MongoJson. When converting back from JSON to RawByteString the binary data gets lost.

Example code:

var
  BV,V: Variant;
  JSON: String;
  RBS : RawByteString;
begin
  TDocVariant.New(V);
  RBS:=#1#2#3;
  BsonVariantType.FromBinary(RBS,bbtGeneric,BV);
  TDocVariantData(V).AddValue('Test',BV);
  JSON:=VariantSaveMongoJson(V,modMongoStrict);
  V:=BsonDocumentToDoc(Bson(JSON));
  BV:=TDocVariantData(V).GetValueOrNull('Test');
  if not VarIsNull(BV) 
    then Result:=BsonVariantType.ToBlob(BV,RBS);
end;

BsonVariantType.ToBlob returns false because it expects another variant type.

#5 mORMot 1 » ExportServerNamedPipe and TSQLRestClientURINamedPipe in mORMot2 » 2022-11-29 15:57:26

Bjoern Henke
Replies: 1

I'm currently trying to convert some code from an ex-colleague to mORMot2.
This code uses ExportServerNamedPipe and TSQLRestClientURINamedPipe for whose I can't find something similar in mORMot2.
(I only found some comments in the mORMot2 code mentioning some NamedPipe things that don't seem to exist either.)

What should I use in mORMot2 instead of ExportServerNamedPipe and TSQLRestClientURINamedPipe?

Board footer

Powered by FluxBB