#1 2022-06-15 12:43:41

tbo
Member
Registered: 2015-04-20
Posts: 353

FormatUtf8() and Variants

Delphi 11.1, mORMot 2.0.3446

Simple example:

var
  i: Integer;
  v: Variant;
  sqlWhere: RawUtf8;
begin
  v := 'Thomas';
  sqlWhere := FormatUtf8('MetaData->>''$.%''=?', ['Creator'], [v], False);
  v := 2;
  sqlWhere := FormatUtf8('MetaData->>''$.%''=?', ['ShutterSpeed'], [v], False);
  i := 2;
  sqlWhere := FormatUtf8('MetaData->>''$.%''=?', ['ShutterSpeed'], [i], False);
end;

Results for sqlWhere:

'MetaData->>''$.Creator''=:(''Thomas''):'
'MetaData->>''$.ShutterSpeed''=:(''2''):'
'MetaData->>''$.ShutterSpeed''=:(2):'

I would expect "v := 2" to give the same result as "i := 2". But it does not. Is that the way it is supposed to be?

With best regards
Thomas

Offline

#2 2022-06-15 14:23:25

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

Re: FormatUtf8() and Variants

It was as implemented in mORMot 1 since years.
And tested as such...

But indeed, it was confusing, and wrong.
So please check https://github.com/synopse/mORMot2/commit/efc3bec4

Offline

Board footer

Powered by FluxBB