You are not logged in.
Pages: 1
Create the following table.
create table if not exists testtbl (
id int4,
prefix "char",
flag char(1),
start time not null default '08:30:00',
stop time not null default '14:30:00');
insert into testtbl (id, prefix, flag, start, stop) values (1, 'P', '1', '08:30:00', '14:30:00'); Define the following ORM.
TOrmtesttbl = class(TOrm)
private
fPrefix: AnsiChar;
fFlag: AnsiChar;
fStart: TTime;
fStop: TTime;
published
property Prefix: AnsiChar read fPrefix write fPrefix;
property Flag: AnsiChar read fFlag write fFlag;
property Start: TTime read fStart write fStart;
property Stop: TTime read fStop write fStop;
end; The following program has an incorrect running result.
DBProps := TSQLDBPostgresConnectionProperties.Create(
'localhost', 'testdb', 'root', 'pass');
DBProps.ThreadSafeConnection.Connect;
Model := TOrmModel.Create([TOrmtesttbl]);
OrmMapExternal(Model, [TOrmtesttbl], DBProps);
Rest := TRestServerDB.Create(Model);
Rest.Model.Owner := Rest;
Rest.Server.CreateMissingTables;
rec := Tormtesttbl.Create;
if Rest.Retrieve(1, rec) then begin
WriteLn('Prefix: ', rec.Prefix); // print P <-- ok
WriteLn('Flag: ', rec.Flag); // print 1 <-- ok
WriteLn(rec.Start, ' ', rec.Stop); // print 0.0000000000000000E+000 0.0000000000000000E+000 <-- error
end;
rec.Prefix := 'M';
rec.Flag := '2';
rec.Start := Time;
rec.Stop := IncMinute(Time, 15);
Rest.Add(rec, True); // <-- ESqlDBException {Message:"Invalid TSqlDBPostgresStatement.Bind(2,TSqlDBFieldType(0),77)" Last edited by idigger (2025-11-17 11:53:52)
Offline
Yes, I try with the latest trunk.
ORM has errors in both the "char" and char(1) columns.
ESqlDBException {Message:"Invalid TSqlDBPostgresStatement.Bind(2,TSqlDBFieldType(0),77)"
or
ESqlDBPostgres {Message:"TSqlDBPostgresLib Exec failed: 22001 [ERROR: value too long for type character(1)
Last edited by idigger (2025-11-17 12:52:25)
Offline
TDateTime is Ok.
WriteLn(DateTimeToStr(rec.Start), ' ', DateTimeToStr(rec.Stop));
Output: 1899-12-30 8:30:00 1899-12-30 14:30:00
Time is Ok.
Last edited by idigger (2025-11-17 12:58:19)
Offline
Does ORM not support postgresql's "char" and char(1)?
Last edited by idigger (2025-11-18 08:21:21)
Offline
I guess it should.
What do you call "support"?
Try first to understand how our DB layer works.
It reduces the number of types to a reduced set, for efficiency and simplificy.
Look e.g. at https://synopse.info/files/html/Synopse … #TITLE_179
Offline
rec.Prefix := 'M'; // "char"
rec.Flag := '2'; // char(1)
rec.Start := Time;
rec.Stop := IncMinute(Time, 15);
Rest.Add(rec, True); // <-- not workRest.Add(rec, True) not work.
ESqlDBException {Message:"Invalid TSqlDBPostgresStatement.Bind(2,TSqlDBFieldType(0),77)"
or
ESqlDBPostgres {Message:"TSqlDBPostgresLib Exec failed: 22001 [ERROR: value too long for type character(1)
Offline
Ok. Thank you very much. I'll give it a try.
Offline
Pages: 1