You are not logged in.
Pages: 1
You are right.
GetValueByPath() should not raise an exception but return false.
I have just updated TDocVariant.Lookup() to reflect this behavior.
Thanks for your quick respond, I see the fix in mormot2
but not in 1.18 , Im using that version, sorry I did not mention it
Hi
According to docs GetValueByPath will return Unassigned if the path does not match with the docvar content, so it seems an easy way to read optional nodes
But this code raises "Exception class EDocVariant with message '[Imps] property not found'. "
v := _Obj([ 'Config', _Obj([]) ]);
m := _Safe(v).GetValueByPath('Config.Imps');
if VarIsEmptyOrNull(m) then
ShowMessage('error');
I try this code too:
v := _Obj([ 'Config', _Obj([]) ]);
if not _Safe(v).GetValueByPath('Config.Imps', m) then
ShowMessage('error');
I can use [dvoReturnNullForUnknownProperty] option but I prefer not, and be more strict and use late binding for required properties (expecting exceptions if not exist) and try read/validate optional nodes with GetValueByPath
Is it the correct behavior ?
thanks
tested with 2 clases TOleDBMSSQLConnectionProperties and TSQLDBFireDACConnectionProperties to connect to SQLServer Express 2014 (localhost win10), Delphi 10.2 Upd3
ReleaseRows was inserted :
> File SynDB.pas
> check-in [a1dfe9124e] at 2020-03-22 11:06:28 on branch trunk
> {5875} reverted ISQLDBRows.RefCount check and introduced an explicit call to new ReleaseRows method
Hi all
I'm trying to export an statement from MSSQL to sqlite with this code:
Result := DB3Conn.NewTableFromRows( ltable, rows, True, colsTypes );
It used to work well but I recently updated mormot sources and I'm getting this error
EDatabaseError with message 'Field '' has no dataset'
Looking into the function found this line "Rows.ReleaseRows;" just before BindFromRows, If comment this line it works.
Rows.ReleaseRows;
// write row data
Ins.BindFromRows(ColumnForcedTypes,Rows);
Ins.ExecutePrepared;
Ins.Reset;
Is it a bug ?
thanks
Just to clarify what im doing and why ask this
I'm generating some xml for electronic signed digital invoice and tax declaration in my country, so I want to validate as much as possible the template and result text to avoid invalid xml
The templates sometimes are created by other people and even though there are manuals, errors occur.
ej:
**Data context sample
{
"DName" : "Jhon Doe",
"DAux" : "",
"DAmount" : 100,
"DTax" : 8
}
**Template
Name is {{DName}}
Aux is {{DAux}}
Amount is {{DAmount}}
Tax is {{DTaxxx}} <- misspelled variable tag
**FinalRender
Name is Jhon Doe
Aux is <- Empty string value OK (key en context)
Amount is 100
Tax is <- Empty value because not found in context (can log variable name DTaxxx in an array for later validation ?? )
I know I can't protect every aspect of the template, but at least for my specific case every variable name in template must be in the data context,
if I could know if there where "tag variables" not rendered because were not found in the data context then I can do something and at least secure a little more the generation of the result xml
The Parser() process already performs the search of variable names recursively within the current context, if not found nothing will be rendered so maybe here just could add the "variable name" to an array just in case someone wants to validate it later
rtext := mustache.Render( vData );
if Length( mustache.VariableTagNotRenderedArray ) > 0 then
begin
showmessage('Template wrong, invalid variables !!');
//todo: maybe display wrong variable names in array
exit;
end;
I just want to explain a little more what I'm trying to achieve and see if is feasible or useful
thanks
I recently need to use mustache engine and I really like it a lot, use to render some xml templates.
Is there a way to know which tags where not found in data context, and not rendered ?
The docs are very clear, when a tag in a template is not found in the current data context nothing wil be rendered (and the tag is deleted in result text)
But some templates are created by users and maybe write wrong tags, right now these tags are just deleted
It would be a great help if know which tags where not found in the data context so can validate and display a warning or raise an error
Maybe have a "MissingTags" property to store tags not found on Parse, so we can do something like this:
rtext := mustache.Render( vData );
//Validate missing tags
if mustache.MissingTags.Count > 0 then
showmessage( mustache.MisingTags.Text );
Or another idea is have a flag to disable delete missing key-tags from the result text, so I can then inspect the result for tags not rendered
Thanks a lot
Im trying to create a mustache helper for FormatFloat:
with _Safe(AValue)^ do
if (Kind=dvArray) and (Count=2) and VariantToDouble(Values[0], lDob) then
begin
AResult := FormatFloat(Values[1],lDob);
end
else
SetVariantNull(AResult);
This works with ej. {{FloatFmt Number, "0.0000"}}
But fails with {{FloatFmt Number, ",0.0000"}} AValue gets [13450.1,"","0.0000\""] (3 values) instead of [13450.1, ",0.0000"](2 values)
The ThousandSeparator is a comma inside the string value but is treated like a separator for array values, I try to escape de comma char {{FloatFmt Number, "\,0.0000"}} but not work
Could it be a bug extracting the values? or how can write the format string ?
Thanks
The same happens to me, I use ReportMemoryLeaksOnShutdown := True;
This causes MemoryLeak
v := _Obj(['token','123']);
v.document := _Obj(['ref', 'abc']);
--This works ok--
v := _Obj(['token','123', 'document',_Obj(['ref','abc']) ]);
--This works ok--
v := TDocVariant.New();
v.token := '123';
v.document := TDocVariant.New();
v.document.ref := 'abc';
Testing latest mormot sources, Windows10 , Delphi XE7
I run into this case too, same thing happen with version "Class: TSynLog 1.18.4001 FTS3"
Is there any news about it?
Thanks
Is there a way to call ServiceRegister from a method to dinamicaly register interfaces on a runing mORMot server ?
Thinking on a kind of plugin framework that in runtime can load, register an interface, client uses the interface then unregister and unload module
Pages: 1