Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / pas2js / 2021-04

Post in TSQLDBRestDataset

13 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Gabriele Cappelletto

Good morning,
i can't modify a TSQLDBRestDataset, ie it seems that the post method is not sending to the server

Server side I put:

FDisp.ExposeDatabase(TIBConnectionDef.TypeName,'localhost','/var/tmpGabry/testrest.fdb','SYSDBA','masterkey',Nil,
            [foFilter,foInInsert,foInUpdate,foOrderByDesc]);

Client side I put:   FData is TSQLDBRestDataset

   FData.Post;
   FData.ApplyUpdates;

  instead I didn't call any method in TSQLDBRestConnection

What did I forget to do?

Thanx

Reply by email

Gabriele Cappelletto
to Gabriele Cappelletto

Sorry but it says "{
   "fMessage": "No key field"
} "
I have to do other checks sorry.

Il 12/04/21 11:47, Gabriele Cappelletto via Pas2js ha scritto:

Show quoted text 31 lines
Good morning, i can't modify a TSQLDBRestDataset, ie it seems that the post method is not sending to the server Server side I put: FDisp.ExposeDatabase(TIBConnectionDef.TypeName,'localhost','/var/tmpGabry/testrest.fdb','SYSDBA','masterkey',Nil,            [foFilter,foInInsert,foInUpdate,foOrderByDesc]); Client side I put:   FData is TSQLDBRestDataset   FData.Post;   FData.ApplyUpdates;   instead I didn't call any method in TSQLDBRestConnection What did I forget to do? Thanx _______________________________________________ Pas2js maillist  -  https://lists.freepascal.org/cgi-bin/mailman/listinfo/pas2js

Reply by email

Gabriele Cappelletto
to Gabriele Cappelletto

I can't solve the problem. How do I declare the primary key to solve the problem below. I tried like this but I don't solve

.Fields.FindByFieldName('ISO').Options := [foInKey];

How should I do?

Thank you

Il 12/04/21 12:00, Gabriele Cappelletto via Pas2js ha scritto:

Show quoted text 41 lines
Sorry but it says "{    "fMessage": "No key field" } " I have to do other checks sorry. Il 12/04/21 11:47, Gabriele Cappelletto via Pas2js ha scritto: > Good morning, > i can't modify a TSQLDBRestDataset, ie it seems that the post method > is not sending to the server > > Server side I put: > > FDisp.ExposeDatabase(TIBConnectionDef.TypeName,'localhost','/var/tmpGabry/testrest.fdb','SYSDBA','masterkey',Nil, > >            [foFilter,foInInsert,foInUpdate,foOrderByDesc]); > > > Client side I put:   FData is TSQLDBRestDataset > > >   FData.Post; >   FData.ApplyUpdates; > >   instead I didn't call any method in TSQLDBRestConnection > > > What did I forget to do? > > Thanx > > > > > > _______________________________________________ > Pas2js maillist  -  > https://lists.freepascal.org/cgi-bin/mailman/listinfo/pas2js _______________________________________________ Pas2js maillist  -  https://lists.freepascal.org/cgi-bin/mailman/listinfo/pas2js

Reply by email

Michael Van Canneyt
to Gabriele Cappelletto
Gabriele Cappelletto wrote 8 lines
I can't solve the problem. How do I declare the primary key to solve the problem below. I tried like this but I don't solve .Fields.FindByFieldName('ISO').Options := [foInKey]; How should I do?

Where do you do this ?

You must do this in the server, after the ExposeDatabase statement.

If you have defined primary keys on the server database fields, they should be picked up by the server. If you didn't then you must define them manually for every table...

Michael.

Reply by email

Gabriele Cappelletto
to Michael Van Canneyt

The test table is this:

CREATE TABLE COUNTRY
(
  ISO char(2) NOT NULL,
  NAME varchar(80) NOT NULL,
  NICENAME varchar(80) NOT NULL,
  ISO3 char(3) DEFAULT NULL,
  NUMCODE smallint,
  PHONECODE smallint NOT NULL,
  CONSTRAINT COUNTRY_PKEY PRIMARY KEY (ISO)
);

The database is firebird 2.5

In the server I wrote:

FDisp.ExposeDatabase(TIBConnectionDef.TypeName,'localhost','/var/tmpGabry/testrest.fdb','SYSDBA','masterkey',Nil,

            [foFilter,foInInsert,foInUpdate,foOrderByDesc]);

but it gives me the problem listed below. So then I wrote

FDisp.ExposeDatabase(TIBConnectionDef.TypeName,'localhost','/var/tmpGabry/testrest.fdb','SYSDBA','masterkey',Nil,

            [foFilter,foInInsert,foInUpdate,foOrderByDesc]);
     With FDisp.Schemas[0].Schema.Resources do
       begin
FindResourceByName('country').Fields.FindByFieldName('ISO').Options:=[foInKey,foInInsert,
foInUpdate,foRequired,foFilter,foOrderBy,foOrderByDesc];
         end;

but it doesn't work anyway. How should I manually declare the primary key?

Thank you

Il 12/04/21 18:26, Michael Van Canneyt ha scritto:

Show quoted text 26 lines
On Mon, 12 Apr 2021, Gabriele Cappelletto via Pas2js wrote: > I can't solve the problem. How do I declare the primary key to solve > the problem below. I tried like this but I don't solve > > > .Fields.FindByFieldName('ISO').Options := [foInKey]; > > > How should I do? Where do you do this ? You must do this in the server, after the ExposeDatabase statement. If you have defined primary keys on the server database fields, they should be picked up by the server. If you didn't then you must define them manually for every table... Michael. _______________________________________________ Pas2js maillist  -  https://lists.freepascal.org/cgi-bin/mailman/listinfo/pas2js

Reply by email

Michael Van Canneyt
to Gabriele Cappelletto
Gabriele Cappelletto wrote 34 lines
The test table is this: CREATE TABLE COUNTRY (   ISO char(2) NOT NULL,   NAME varchar(80) NOT NULL,   NICENAME varchar(80) NOT NULL,   ISO3 char(3) DEFAULT NULL,   NUMCODE smallint,   PHONECODE smallint NOT NULL,   CONSTRAINT COUNTRY_PKEY PRIMARY KEY (ISO) ); The database is firebird 2.5 In the server I wrote: FDisp.ExposeDatabase(TIBConnectionDef.TypeName,'localhost','/var/tmpGabry/testrest.fdb','SYSDBA','masterkey',Nil,            [foFilter,foInInsert,foInUpdate,foOrderByDesc]); but it gives me the problem listed below. So then I wrote FDisp.ExposeDatabase(TIBConnectionDef.TypeName,'localhost','/var/tmpGabry/testrest.fdb','SYSDBA','masterkey',Nil,            [foFilter,foInInsert,foInUpdate,foOrderByDesc]);     With FDisp.Schemas[0].Schema.Resources do       begin FindResourceByName('country').Fields.FindByFieldName('ISO').Options:=[foInKey,foInInsert, foInUpdate,foRequired,foFilter,foOrderBy,foOrderByDesc];         end;

That should be enough. The foInKey tells the server to use the field ISO as the primary key.

Together with the client-side
FieldByname('ISO').ProviderFlags:=[pfInkey,pfInUpdate];

It should work. (you obviously need both)

A mechanism to set the client-side field properties based on server-side metadadata (all data is available, after all) is still on my todo list...

Michael.

Reply by email

Michael Van Canneyt
to Gabriele Cappelletto

Strange...

Can you please provide a server stacktrace ?
Because without that, there is little I can do to analyse the problem.

Michael.

Gabriele Cappelletto wrote 67 lines
I made a few attempts, inserting a new record works, but editing and deleting give this result on the server: Exception 'EJSON' Duplicate object member: "error" Il 12/04/21 21:29, Michael Van Canneyt ha scritto: On Mon, 12 Apr 2021, Gabriele Cappelletto via Pas2js wrote: The test table is this: CREATE TABLE COUNTRY (   ISO char(2) NOT NULL,   NAME varchar(80) NOT NULL,   NICENAME varchar(80) NOT NULL,   ISO3 char(3) DEFAULT NULL,   NUMCODE smallint,   PHONECODE smallint NOT NULL,   CONSTRAINT COUNTRY_PKEY PRIMARY KEY (ISO) ); The database is firebird 2.5 In the server I wrote: FDisp.ExposeDatabase(TIBConnectionDef.TypeName,'localhost','/var/tmpGabry/testrest.fdb','SYSDBA','masterkey',Nil,            [foFilter,foInInsert,foInUpdate,foOrderByDesc]); but it gives me the problem listed below. So then I wrote FDisp.ExposeDatabase(TIBConnectionDef.TypeName,'localhost','/var/tmpGabry/testrest.fdb','SYSDBA','masterkey',Nil,            [foFilter,foInInsert,foInUpdate,foOrderByDesc]);     With FDisp.Schemas[0].Schema.Resources do       begin FindResourceByName('country').Fields.FindByFieldName('ISO').Options:=[foInKey,foInInsert, foInUpdate,foRequired,foFilter,foOrderBy,foOrderByDesc];         end; That should be enough. The foInKey tells the server to use the field ISO as the primary key. Together with the client-side FieldByname('ISO').ProviderFlags:=[pfInkey,pfInUpdate]; It should work. (you obviously need both) A mechanism to set the client-side field properties based on server-side metadadata (all data is available, after all) is still on my todo list... Michael. _______________________________________________ Pas2js maillist - https://lists.freepascal.org/cgi-bin/mailman/listinfo/pas2js

Reply by email

Gabriele Cappelletto
to Michael Van Canneyt

#0 fpc_raiseexception at :0
#1 FPJSON$_$TJSONDATA_$__$$_DOERROR$ANSISTRING$array_of_const at :0 #2
FPJSON$_$TJSONOBJECT_$__$$_DOADD$UTF8STRING$TJSONDATA$BOOLEAN$$LONGINT at :0
#3 .Ld6$strlab at :0
#4 ?? at :0
#5 ?? at :0
#6 .Ld6$strlab at :0
#7 ?? at :0
#8 ?? at :0
#9 ?? at :0

I don't know or am I doing something wrong, the instructions to modify are:

   FData.FieldByName('iso').ProviderFlags:=[pfInkey,pfInUpdate];
   FData.First;
   FData.Edit;
   FData.FieldByName('NAME').AsString:='romp';
   FData.Post;
   FData.ApplyUpdates;

Il 13/04/21 12:06, Michael Van Canneyt ha scritto:

Show quoted text 81 lines
Strange... Can you please provide a server stacktrace ? Because without that, there is little I can do to analyse the problem. Michael. On Tue, 13 Apr 2021, Gabriele Cappelletto via Pas2js wrote: > > I made a few attempts, inserting a new record works, but editing and > deleting give this result on the server: > > > Exception 'EJSON' > > Duplicate object member: "error" > > > Il 12/04/21 21:29, Michael Van Canneyt ha scritto: > > >       On Mon, 12 Apr 2021, Gabriele Cappelletto via Pas2js wrote: > >             The test table is this: > >             CREATE TABLE COUNTRY >             ( >               ISO char(2) NOT NULL, >               NAME varchar(80) NOT NULL, >               NICENAME varchar(80) NOT NULL, >               ISO3 char(3) DEFAULT NULL, >               NUMCODE smallint, >               PHONECODE smallint NOT NULL, >               CONSTRAINT COUNTRY_PKEY PRIMARY KEY (ISO) >             ); > >             The database is firebird 2.5 > >             In the server I wrote: > > FDisp.ExposeDatabase(TIBConnectionDef.TypeName,'localhost','/var/tmpGabry/testrest.fdb','SYSDBA','masterkey',Nil, > [foFilter,foInInsert,foInUpdate,foOrderByDesc]); > > >             but it gives me the problem listed below. So then I wrote > > > FDisp.ExposeDatabase(TIBConnectionDef.TypeName,'localhost','/var/tmpGabry/testrest.fdb','SYSDBA','masterkey',Nil, > [foFilter,foInInsert,foInUpdate,foOrderByDesc]); > >                 With FDisp.Schemas[0].Schema.Resources do >                   begin > FindResourceByName('country').Fields.FindByFieldName('ISO').Options:=[foInKey,foInInsert, > foInUpdate,foRequired,foFilter,foOrderBy,foOrderByDesc]; >                     end; > > >       That should be enough. The foInKey tells the server to use the > field ISO as >       the primary key. > >       Together with the client-side >       FieldByname('ISO').ProviderFlags:=[pfInkey,pfInUpdate]; > >       It should work. (you obviously need both) > >       A mechanism to set the client-side field properties based on > server-side >       metadadata (all data is available, after all) is still on my > todo list... > >       Michael. > > _______________________________________________ > Pas2js maillist  -  > https://lists.freepascal.org/cgi-bin/mailman/listinfo/pas2js > > >

Reply by email

Gabriele Cappelletto
to Gabriele Cappelletto

Do you want me to attach the whole project to try?

Il 13/04/21 12:14, Gabriele Cappelletto via Pas2js ha scritto:

Show quoted text 112 lines
#0 fpc_raiseexception at :0 #1 FPJSON$_$TJSONDATA_$__$$_DOERROR$ANSISTRING$array_of_const at :0 #2 FPJSON$_$TJSONOBJECT_$__$$_DOADD$UTF8STRING$TJSONDATA$BOOLEAN$$LONGINT at :0 #3 .Ld6$strlab at :0 #4 ?? at :0 #5 ?? at :0 #6 .Ld6$strlab at :0 #7 ?? at :0 #8 ?? at :0 #9 ?? at :0 I don't know or am I doing something wrong, the instructions to modify are:   FData.FieldByName('iso').ProviderFlags:=[pfInkey,pfInUpdate];   FData.First;   FData.Edit;   FData.FieldByName('NAME').AsString:='romp';   FData.Post;   FData.ApplyUpdates; Il 13/04/21 12:06, Michael Van Canneyt ha scritto: > > Strange... > > Can you please provide a server stacktrace ? Because without that, > there is little I can do to analyse the problem. > > Michael. > > On Tue, 13 Apr 2021, Gabriele Cappelletto via Pas2js wrote: > >> >> I made a few attempts, inserting a new record works, but editing and >> deleting give this result on the server: >> >> >> Exception 'EJSON' >> >> Duplicate object member: "error" >> >> >> Il 12/04/21 21:29, Michael Van Canneyt ha scritto: >> >> >>       On Mon, 12 Apr 2021, Gabriele Cappelletto via Pas2js wrote: >> >>             The test table is this: >> >>             CREATE TABLE COUNTRY >>             ( >>               ISO char(2) NOT NULL, >>               NAME varchar(80) NOT NULL, >>               NICENAME varchar(80) NOT NULL, >>               ISO3 char(3) DEFAULT NULL, >>               NUMCODE smallint, >>               PHONECODE smallint NOT NULL, >>               CONSTRAINT COUNTRY_PKEY PRIMARY KEY (ISO) >>             ); >> >>             The database is firebird 2.5 >> >>             In the server I wrote: >> >> FDisp.ExposeDatabase(TIBConnectionDef.TypeName,'localhost','/var/tmpGabry/testrest.fdb','SYSDBA','masterkey',Nil, >> >> [foFilter,foInInsert,foInUpdate,foOrderByDesc]); >> >> >>             but it gives me the problem listed below. So then I wrote >> >> >> FDisp.ExposeDatabase(TIBConnectionDef.TypeName,'localhost','/var/tmpGabry/testrest.fdb','SYSDBA','masterkey',Nil, >> >> [foFilter,foInInsert,foInUpdate,foOrderByDesc]); >> >>                 With FDisp.Schemas[0].Schema.Resources do >>                   begin >> FindResourceByName('country').Fields.FindByFieldName('ISO').Options:=[foInKey,foInInsert, >> >> foInUpdate,foRequired,foFilter,foOrderBy,foOrderByDesc]; >>                     end; >> >> >>       That should be enough. The foInKey tells the server to use the >> field ISO as >>       the primary key. >> >>       Together with the client-side >>       FieldByname('ISO').ProviderFlags:=[pfInkey,pfInUpdate]; >> >>       It should work. (you obviously need both) >> >>       A mechanism to set the client-side field properties based on >> server-side >>       metadadata (all data is available, after all) is still on my >> todo list... >> >>       Michael. >> >> _______________________________________________ >> Pas2js maillist  -  >> https://lists.freepascal.org/cgi-bin/mailman/listinfo/pas2js >> >> >> _______________________________________________ Pas2js maillist  -  https://lists.freepascal.org/cgi-bin/mailman/listinfo/pas2js

Reply by email

Michael Van Canneyt
to Gabriele Cappelletto

You can send it to me in private, yes...

Michael.

Gabriele Cappelletto wrote 124 lines
Do you want me to attach the whole project to try? Il 13/04/21 12:14, Gabriele Cappelletto via Pas2js ha scritto: > #0 fpc_raiseexception at :0 > #1 FPJSON$_$TJSONDATA_$__$$_DOERROR$ANSISTRING$array_of_const at :0 > #2 > FPJSON$_$TJSONOBJECT_$__$$_DOADD$UTF8STRING$TJSONDATA$BOOLEAN$$LONGINT > at :0 > #3 .Ld6$strlab at :0 > #4 ?? at :0 > #5 ?? at :0 > #6 .Ld6$strlab at :0 > #7 ?? at :0 > #8 ?? at :0 > #9 ?? at :0 > > I don't know or am I doing something wrong, the instructions to modify > are: > >   FData.FieldByName('iso').ProviderFlags:=[pfInkey,pfInUpdate]; >   FData.First; >   FData.Edit; >   FData.FieldByName('NAME').AsString:='romp'; >   FData.Post; >   FData.ApplyUpdates; > > > Il 13/04/21 12:06, Michael Van Canneyt ha scritto: >> >> Strange... >> >> Can you please provide a server stacktrace ? Because without that, >> there is little I can do to analyse the problem. >> >> Michael. >> >> On Tue, 13 Apr 2021, Gabriele Cappelletto via Pas2js wrote: >> >>> >>> I made a few attempts, inserting a new record works, but editing and >>> deleting give this result on the server: >>> >>> >>> Exception 'EJSON' >>> >>> Duplicate object member: "error" >>> >>> >>> Il 12/04/21 21:29, Michael Van Canneyt ha scritto: >>> >>> >>>       On Mon, 12 Apr 2021, Gabriele Cappelletto via Pas2js wrote: >>> >>>             The test table is this: >>> >>>             CREATE TABLE COUNTRY >>>             ( >>>               ISO char(2) NOT NULL, >>>               NAME varchar(80) NOT NULL, >>>               NICENAME varchar(80) NOT NULL, >>>               ISO3 char(3) DEFAULT NULL, >>>               NUMCODE smallint, >>>               PHONECODE smallint NOT NULL, >>>               CONSTRAINT COUNTRY_PKEY PRIMARY KEY (ISO) >>>             ); >>> >>>             The database is firebird 2.5 >>> >>>             In the server I wrote: >>> >>> FDisp.ExposeDatabase(TIBConnectionDef.TypeName,'localhost','/var/tmpGabry/testrest.fdb','SYSDBA','masterkey',Nil, >>> >>> [foFilter,foInInsert,foInUpdate,foOrderByDesc]); >>> >>> >>>             but it gives me the problem listed below. So then I wrote >>> >>> >>> FDisp.ExposeDatabase(TIBConnectionDef.TypeName,'localhost','/var/tmpGabry/testrest.fdb','SYSDBA','masterkey',Nil, >>> >>> [foFilter,foInInsert,foInUpdate,foOrderByDesc]); >>> >>>                 With FDisp.Schemas[0].Schema.Resources do >>>                   begin >>> FindResourceByName('country').Fields.FindByFieldName('ISO').Options:=[foInKey,foInInsert, >>> >>> foInUpdate,foRequired,foFilter,foOrderBy,foOrderByDesc]; >>>                     end; >>> >>> >>>       That should be enough. The foInKey tells the server to use the >>> field ISO as >>>       the primary key. >>> >>>       Together with the client-side >>>       FieldByname('ISO').ProviderFlags:=[pfInkey,pfInUpdate]; >>> >>>       It should work. (you obviously need both) >>> >>>       A mechanism to set the client-side field properties based on >>> server-side >>>       metadadata (all data is available, after all) is still on my >>> todo list... >>> >>>       Michael. >>> >>> _______________________________________________ >>> Pas2js maillist  -  >>> https://lists.freepascal.org/cgi-bin/mailman/listinfo/pas2js >>> >>> >>> > _______________________________________________ > Pas2js maillist  -  > https://lists.freepascal.org/cgi-bin/mailman/listinfo/pas2js _______________________________________________ Pas2js maillist - https://lists.freepascal.org/cgi-bin/mailman/listinfo/pas2js

Reply by email

Mgr. Janusz Chmiel
to Michael Van Canneyt: Strange... Can you please provide a server stacktrace ? Because without that, there is…

Dear specialists,
I have installed Visualstudio Code and latest stable pas2js extension and I do not know how to use it. First of all, I have specified The paths for all necessary tools including pas2js path. But I do not know how to find the possibility to create new Pas2js project. Main menu contain only new file and there is no project sub menu. Visual studio have been made professionally by Microsoft to support screen readers. As A result, Visual studio code autodetect The presence of running screen reader and it configures automatically for it. I have found pas2js project settings, but how to control The project? Sure, I know, that I can not open existing Lazarus .lpi project files, I will be working with Visual studio code. But how to operate The visual studio so this extension Pas2js will be usable to create new project? If I have setup all paths. It is necessary to specify full path with .exe app name, or giving only folders is enough? Do I have to compile form creator in The pas2js tools or I only must specify pathto The folder? Thank you very much for yours answers.
WWith kindnes regards.
Janusz Chmiel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/pas2js/attachments/20210430/51bd76af/attachment.htm>

Reply by email