#1 mORMot 1 » Execute firebird stored procedure via mormot » 2017-04-08 00:46:28

dolfin
Replies: 1

Hello!

I use mormot framework together with firebird db.
Is ther any way to execute custom sql query using mormot? I need execute stored procedure with params, and i don't know if it is possible.
I tried something like this, but with no luck.

FConnectionDefinition: TSynConnectionDefinition;
...
vDBConnectionParams := TSQLDBZEOSConnectionProperties.CreateFrom(FConnectionDefinition) as TSQLDBZEOSConnectionProperties;
vSQLDBStatementWithParamsAndColumns:= TSQLDBZEOSStatement.Create(vDBConnectionParams.NewConnection);
vSQLDBStatementWithParamsAndColumns.Connection.Connect;
vSQLDBStatementWithParamsAndColumns.Connection.StartTransaction;
vSQLDBStatementWithParamsAndColumns.Prepare('select OUTPUT_INT from TEST_MORMOT_PROC(1)');
vSQLDBStatementWithParamsAndColumns.ExecutePrepared;
vSQLDBStatementWithParamsAndColumns.Connection.Commit;

Many thx in advance!

#2 Re: mORMot 1 » Search engine » 2017-02-12 17:59:39

Thanks for clarification! But I still have no progress with my task. I found a stemmer for russian and ukrainian languages (https://github.com/ermakovpetr/stemka), but I don't know how to make it work with mormot and sqlite. Could you please give an advice regarding this problem?

#3 Re: mORMot 1 » Search engine » 2017-02-12 14:34:24

I am developing application with fts feature using mormot framework. The key problem is that I need stemmer for russian and ukrainian languages.
What is the proper way to load custom stemmer dll for sqlite using mormot framework?

#4 mORMot 1 » TSQLRecord custom serialization » 2017-01-05 18:30:59

dolfin
Replies: 1

Hello!

Is there any possibility to perform custom TSQLRecord serialization?

The problem is that I need to map my Model's properties names to different names. For example in my Model I have published property "Name" and as a result I get such a JSON on certain REST server call:  {"Name": "test"}. But I need to have a possibility to change this property name to get something like {"_name": "test"}. I tried to use TJSONSerializer.RegisterCustomSerializer(TMySQLRecord, nil, TMySQLRecord.FVClassWriter); but custom serialization method is not called on REST request. Custom serialization methos is called only on explicity ObjectToJson function call.

Many thanks in advanced!

#5 Re: mORMot 1 » Firebird db objects names capitalization issue » 2016-03-16 16:40:01

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!

#7 Re: mORMot 1 » Firebird db objects names capitalization issue » 2016-03-16 13:42:20

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?

#8 Re: mORMot 1 » Error on call TSQLHttpClientWinHTTP.UpdateField » 2016-01-28 15:26:45

Hi!

Do you have any news on the issue?
May be you need something else for investigations?

#9 Re: mORMot 1 » Case insensitive sql like function » 2016-01-26 14:52:19

Thanks for the idea. But how I will force the framework to use my funciton instead of builtin one.
I'd not want to change source files.

#10 Re: mORMot 1 » Case insensitive sql like function » 2016-01-26 14:09:20

I played a little bit more with where clause and found out that the problem happens only with cyrillic characters. For latin characters everything works fine. So comparison for letters 'я' and 'Я' is different.
How can I deal with this issue?

#11 mORMot 1 » Case insensitive sql like function » 2016-01-26 12:58:18

dolfin
Replies: 8

Hi!

Is there any way to force like active case-insesitivly?
I have a REST server and trying to perform such request fom ajax client:
http://localhost:8080/root/guest/?select=*&where=Name like '%a%'
and I want to get both "...a..." and "...A..." values in the results.
How can I achieve this?

#12 Re: mORMot 1 » Error on call TSQLHttpClientWinHTTP.UpdateField » 2016-01-26 12:53:23

Please check the log below:

20160126 12411953  C ERROR mORMotSQLite3.TSQLRestServerDB(03BAB390) {"EORMException(03E6A680)":{"Message":"TSQLRestServerDB.GetAndPrepareStatement(UPDATE SrvMamClient SET TaskCount=?,TSQLPropInfoRTTIRecordVersion=? WHERE RowID=?) recognized 3 params, and 0 for SQLite3"}} for UPDATE SrvMamClient SET TaskCount=:(2):,TSQLPropInfoRTTIRecordVersion=:(1771): WHERE RowID=:(3): // UPDATE SrvMamClient SET TaskCount=?,TSQLPropInfoRTTIRecordVersion=? WHERE RowID=? stack trace API 005C79EB mORMot.TSQLRest.InternalLog (31496) 0061E9D6 mORMotSQLite3.TSQLRestServerDB.GetAndPrepareStatementRelease (767) 00620393 mORMotSQLite3.TSQLRestServerDB.InternalExecute (1152) 0062070F mORMotSQLite3.TSQLRestServerDB.EngineExecute (1213) 005CB61C mORMot.TSQLRest.ExecuteFmt (32641) 00621E2E mORMotSQLite3.TSQLRestServerDB.MainEngineUpdateField (1499) 005E3A38 mORMot.TSQLRestServer.EngineUpdateField (39014) 005D9F0E mORMot.TSQLRestServerURIContext.ExecuteORMWrite (36869) 006096BC mORMot.BackgroundExecuteProc (51396) 0054DB62 SynCommons.TSynBackgroundThreadMethod.Process (52119) 0054D5DF SynCommons.TSynBackgroundThreadAbstract.Execute (51988) 004C4A8C System.Classes.ThreadProc (14361) 0040B51A System.ThreadWrapper (24233)

#13 Re: mORMot 1 » Error on call TSQLHttpClientWinHTTP.UpdateField » 2016-01-25 14:32:11

Yes, I used version '1.18.2291'.

stack trace API 00553E62
005C41FF 00619112 0061AA78 0061ADF3 005C7D3C 0061C470 005DF5E8 005D5BBC 00604FFC 0054BF5A 0054B9D7 004C4A8C 0040B51A 754F338A 772497F2 772497C5

I can provide you with test project (modified 04 - HTTP Client-Server) if necessarily.

#14 mORMot 1 » Error on call TSQLHttpClientWinHTTP.UpdateField » 2016-01-25 11:33:17

dolfin
Replies: 6

Hello!

I faced with strange behavior while call method TSQLHttpClientWinHTTP.UpdateField on class inherited from TSQLRecord which contains TRecordVersion type property. If there is a published property of type TRecordVersion in class inherited from TSQLRecord then call of method TSQLHttpClientWinHTTP.UpdateField produces the following error:

20160124 17052021  C ERROR mORMotSQLite3.TSQLRestServerDB(032FA430) {"EORMException(04133CD0)":{"Message":"TSQLRestServerDB.GetAndPrepareStatement(UPDATE SrvMamClient SET TaskCount=?,TSQLPropInfoRTTIRecordVersion=? WHERE RowID=?) recognized 3 params, and 0 for SQLite3"}} for UPDATE SrvMamClient SET TaskCount=:(1):,TSQLPropInfoRTTIRecordVersion=:(1579848): WHERE RowID=:(1): // UPDATE SrvMamClient SET TaskCount=?,TSQLPropInfoRTTIRecordVersion=? WHERE RowID=?

Please check the code below:

  HttpClient: TSQLHttpClientWinHTTP;
  TSrvMamClient: TSQLRecord;
  HttpClient.UpdateField(TSrvMamClient, 1, 'TaskCount', 1)

If I comment property of type TRecordVersion in TSrvMamClient class everything works fine.

#15 Re: mORMot 1 » Unique validation on ajax request » 2015-11-30 15:54:38

Well, I think the best idea is to have a possibility to add a validator on server side, wich will process the requests and responses with custom json or at least with custom error message like "errorText":"'Name' field must be unique".   
As I know usually "422 Unprocessable Entity" or "409 Conflict" errors are used in such case.

#16 mORMot 1 » Unique validation on ajax request » 2015-11-30 10:19:37

dolfin
Replies: 4

Hello!
I  have a simple TSQLRecord class with one unique field:

type
  TCategory = class(TSQLRecord)
  private
    FName: RawUTF8;
  published
    property Name: RawUTF8 index 64 read FName write FName stored AS_UNIQUE;
  end;

If ajax post request is performed with "Name" value wich is already exists, the server respones with such answer:

{
  "errorCode":400,
  "errorText":"Bad Request"
}

And there is no detail info on what was wrong. I tried to use validators to get more relevant answer(for example "errorText":"Name field must be unique") but with no luck. As I understood to use a validator I have to define my own server method and explicitly call Rec.Validate method. Am I right? And what is the right way to perform filter and validation while working with ajax client?

Many thanks in advance!

#17 Re: mORMot 1 » Perform ComputeFieldsBeforeWrite on server side » 2015-10-23 09:04:41

Ok, no problem. I've created a ticket and you can check it by link: http://synopse.info/fossil/tktview/f65e … e8d6c38c00
Thanks for help!

#18 mORMot 1 » Perform ComputeFieldsBeforeWrite on server side » 2015-10-22 16:38:35

dolfin
Replies: 4

Hello!

Is there any possibility to run ComputeFieldsBeforeWrite method on server side after ajax request?
I just need to calculate fields value depending on another field value.


Many thanks in advance!

#19 mORMot 1 » Firebird db objects names capitalization issue » 2015-09-22 08:22:48

dolfin
Replies: 5

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?

#20 Re: mORMot 1 » Get true JSON object on AJAX request » 2015-09-15 21:16:39

That's awesome, great thx for that!
And I have one more question, dealing ajax. Is it possible to return some data, for example ID, after POST request?

#21 Re: mORMot 1 » Get true JSON object on AJAX request » 2015-09-14 15:11:22

Greate news, thank you very much for a fast fix!
You did this fix for  /tablename/id query, is it possible to add this improvement for /tablename/?select=* query also? I would be very grateful if you would do it.

#22 mORMot 1 » Get true JSON object on AJAX request » 2015-09-11 13:00:23

dolfin
Replies: 6

I faced with issue dealing with transmitted JSON content from server to ajax client application.
I have the following code:

type
TPersist = class(TPersistent)
   private
    FFileName     : RawUtf8;
    FDisplayName  : RawUtf8;
  published
   property FileName     : RawUtf8  read FFileName     write FFileName;
   property DisplayName  : RawUtf8  read FDisplayName  write FDisplayName;
  end;

TSQLBaby = class(TSQLRecord)
private
  fName: RawUTF8;
  FPersistField: TPersist;
published
  property Name: RawUTF8 read fName write fName;
  property PersistField : TPersist read FPersistField write FPersistField ;
end;

p:=TPersist.Create;
Baby.FPersistField := p;
p.FFileName := 'This is file name';
p.FDisplayName := 'This is display name';
Client.Add(Baby,true);

And by going to uri: http://localhost:8080/root/baby/26 I get the following answer:
{"ID":26,"Name":"TEST_COL_LIST","PersistField":"{\"FileName\":\"This is file name\",\"DisplayName\":\"This is display name\"}"}

The issue is that I get PersistField as string"{\"FileName\":\"This is file name\",\"DisplayName\":\"This is display name\"}"} but I want to get a true JSON object.

I found next info in the manual:
Up to revision 1.15 of the framework, the transmitted JSON content was not a true JSON object, but
sent  as  RawUTF8  TEXT  values  (i.e.  every  double-quote  (")  character  is  escaped  as   -  e.g.
"UTF8":"[32]").  Starting  with  revision  1.16  of  the  framework,  the  transmitted  data  is  a  true  JSON
object, to allow better integration with an AJAX client. That is, UTF8 field is transmitted as a valid JSON
array of string, and Persistent as a valid JSON object with nested objects and arrays.

As I understood, since I use version 1.18 I should receive a true json object.

Could you please help me on this issue?

Board footer

Powered by FluxBB