You are not logged in.
Pages: 1
Hi, I use external firebird db as a data store and TSQLDATASET ConnectionProperties class to interact with it. Unfortunately all tables and there fields names are stored in the db in capitalize form. The problem is I get JSON object in capitalize form too, in spite of Delphi objects names are written in camel case. I begun my project using sqlite db(for sql lite everything works fine) and now I need to switch to firebird db and as Javascript is case sensitive I have to change a lot of code. I think the serialized object should have names as it is set in delphi and do not depend on db or driver. What is the best way to solve this issue?
Offline
You could try to map the field names, giving explicitly uppercased names for the external database.
Offline
Hello!
I faced with new issue while getting JSON object response with fields in the upper case. Let me first describe my situation.
I tried to map fields as you suggest but with no luck(But still thank you for your idea, I used it for making table field's names more readable in the db). And unexpectedly I
discovered that if I add variant field to any model everything works as I need. The fields names are exectly as I set in the Model.
My model is:
type
TProgramPlanDeleted = class(TSQLRecord)
private
FDeletedPlanId: TID;
FCreateTime: TDateTime;
FComment: Variant;
published
property DeletedPlanId: TID read FDeletedPlanId write FDeletedPlanId;
property CreateTime: TDateTime read FCreateTime write FCreateTime;
property Comment: Variant read FComment write FComment;
end;
So without variant field "Comment" I get(http://local:8080/root/ProgramPlanDeleted/1):
{
ID: 1,
DELETEDPLANID: 2,
CREATETIME: "2016-03-16"
}
And if I add variant field "Comment" I get:
{
ID: 1,
DeletedPlanId: 2,
CreateTime: "2016-03-16",
Comment: {
a: 1
}
}
So I resolved the issue by adding variant field to any model I use. But unfortunetly this worked only with version '1.18.1907'.
Today I updated my mormot to latest version and faced this issue again. For now in spite of variant field I always get such result:
{
ID: 1,
DELETEDPLANID: 2,
CREATETIME: "2016-03-16"
}
I remind that this happens only when working with firebird db. I can't refuse from firebird nighther want to stay on old mormot version.
Could you please provide any help on this issue?
Offline
Thank you very much!!! It works as magic!
Offline
I played with TSQLRestServer options and faced with a few issues.
First of all I really want to say thank you for realization of soAddUpdateReturnsContent and rsoComputeFieldsBeforeWriteOnServerSide features but could you please clarify some details of its behavior:
1. Regarding rsoGetAsJsonNotAsString: if Model doesn't contain variant field the JSON response contains its fields in the uppercase. If model contains any variant field everything works fine. I think such behavior is a bit confusing.
2. Regarding soAddUpdateReturnsContent: The response always contains object fields in the upper case.
3. Regarding rsoComputeFieldsBeforeWriteOnServerSide: It works fine for fields TModTime / TCreateTime but if I perform PUT or POST request with only few fields (not with all fields of the model) then in "onBeforeWrite" function it is possible to modify only these fields. It is a bit inconvenient as for example I need to update only one field of the model (for example "Name") but on the server side I need to update another field "last_change_user_name" in "onBeforeWrite" function and for now I can’t do that.
Many thanks in advance!
Offline
Pages: 1