You are not logged in.
Pages: 1
Hi AB,
I'm trying to add users to authuser.
At the second start of the program I have four, but I can not add the fifth.
No error or exception, but in the end I found the answer in the log:
There is a problem with the self-generation of _ID
function TSQLRestStorageMongoDB.EngineNextID: TID;
procedure ComputeMax_ID;
var res: variant;
begin
if not fIndexesCreated then
CreateIndexes;
res := fCollection.AggregateDoc('{$group:{_id:null,max:{$max:"$_id"}}}'); <----- WRONG, works only in shell
if DocVariantType.IsOfType(res) then
fEngineLastID := VariantToInt64Def(res.max,0);
{$ifdef WITHLOG}
fOwner.LogFamily.SynLog.Log(sllInfo,'Computed EngineNextID=%',[fEngineLastID],self);
{$endif}
end;
Error from log
20150115 01380705 SQL {collection:"MAINHEAD.$cmd",opCode:"opQuery",requestID:5,query:{aggregate:"AuthUser",pipeline:"{$group:{_id:0,max:{$max:\"$_id\"}}}"},numberToReturn:1}
20150115 01380746 DB {ReplyHeader:{ResponseFlags:8,RequestID:49,ResponseTo:5,CursorID:0,StartingFrom:0,NumberReturned:1,ReplyDocuments:[{errmsg:"exception: wrong type for field (pipeline) 2 != 4",code:13111,ok:0}]}
Looking around I found these:
http://docs.mongodb.org/manual/referenc … op._S_type
http://stackoverflow.com/questions/1239 … 3111-error
Offline
I suspect there is something wrong with your framework units (SynMongoDB+mORMotMongoDB).
With the current version, I've got the following command:
{aggregate:"perftest",pipeline:[{$group:{_id:null,max:{$max:"$_id"}}}]
... which sounds correct to me, and returns
{"result":null,"ok":1}
.
Offline
I made a test project.
The program adds a user randomly at each start, the first works, but the second does not work.
I get the same result with xe2 and XE7, mongodb 2.6.1 and 2.6.6.
Offline
any news ?
works with your setup?
Offline
I found the problem!
These two functions are not equivalent:
1) function TMongoCollection.AggregateCall(const pipelineJSON: RawUTF8; var reply,res: variant): boolean;
2) function TMongoCollection.AggregateCall(const pipelineArray: variant; var reply,res: variant): boolean;
The first works well.
The second one does not insert properly the pipeline as an array.
Temporary patch:
function TMongoCollection.AggregateDoc(const pipelineArray: variant): variant;
var reply: variant;
begin
if AggregateCall(RAWutf8(pipelineArray),reply,result) then // I added RAWutf8 to force the use of the first
TDocVariant.GetSingleOrDefault(result,result,result) else
SetVariantNull(result);
end;
Last edited by Sabbiolina (2015-01-15 19:17:11)
Offline
It worked with Delphi 7, but not with Delphi XE7....
The overloaded methods were not interpreted the same.
I've renamed TCollection.AggregateDoc() / AggregateJSON() overloaded methods to distinct methods specifying their input parameter type.
See http://synopse.info/fossil/info/a4ca5c4946
Should work as expected now.
Sorry for the delay, but I was focusing on implementing Intel AES-NI hardware acceleration to SynCrypto.pas - which works very nicely now - so it was a single task to write such low level assembler code.
See http://synopse.info/fossil/info/4b79a0d89e66f7
Offline
The first tests seems to work well.
Offline
Pages: 1