-
-
Save rudiloos/dcbc66a8858ff8c2188f2ea0edb7989f to your computer and use it in GitHub Desktop.
mORMot2 batch error
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
program BatchAddError; | |
{$APPTYPE CONSOLE} | |
{$I mormot.defines.inc} | |
uses | |
{$I mormot.uses.inc} | |
SysUtils, | |
mormot.core.os, | |
mormot.core.text, | |
mormot.core.base, | |
mormot.core.json, | |
mormot.core.data, | |
mormot.core.unicode, | |
mormot.core.datetime, | |
mormot.orm.base, | |
mormot.orm.core, | |
mormot.rest.sqlite3, | |
mormot.db.sql.sqlite3, | |
mormot.db.raw.sqlite3, | |
mormot.db.raw.sqlite3.static; | |
type | |
TBaseRecord = class(TOrm) | |
protected | |
fCreatedOn : TTimeLog; | |
fCreatedBy : RawUTF8; | |
fEditedOn : TTimeLog; | |
fEditedBy : RawUTF8; | |
fNotes : RawUTF8; | |
fRecVers : TRecordVersion; | |
fRecStatus : Int64; | |
published | |
property CreatedOn : TTimeLog read fCreatedOn write fCreatedOn; | |
property CreatedBy : RawUTF8 read fCreatedBy write fCreatedBy; | |
property EditedOn : TTimeLog read fEditedOn write fEditedOn; | |
property EditedBy : RawUTF8 read fEditedBy write fEditedBy; | |
property Notes : RawUTF8 read fNotes write fNotes; | |
property RecVers : TRecordVersion read fRecVers write fRecVers; | |
property RecStatus : Int64 read fRecStatus write fRecStatus; | |
end; | |
TFileRec = class(TBaseRecord) | |
protected | |
fFile_Name : RawUTF8; | |
fFile_Type : RawUTF8; | |
fFile_Ext : RawUTF8; | |
fFile_Size : Int64; | |
fFile_Date : TDateTime; | |
fFile_MD5 : RawUTF8; | |
published | |
property File_Name : RawUTF8 read fFile_Name write fFile_Name; | |
property File_Type : RawUTF8 read fFile_Type write fFile_Type; | |
property File_Ext : RawUTF8 read fFile_Ext write fFile_Ext; | |
property File_Size : Int64 read fFile_Size write fFile_Size; | |
property File_Date : TDateTime read fFile_Date write fFile_Date; | |
property File_MD5 : RawUTF8 read fFile_MD5 write fFile_MD5; | |
end; | |
TOrmTest = class(TFileRec) | |
private | |
fProjID : Int64; | |
fDoneOn : TDateTime; | |
fDoneBy : RawUTF8; | |
fCOCNo : RawUTF8; | |
fCOCType : RawUTF8; | |
fSentOn : TDateTime; | |
fSentTo : RawUTF8; | |
fDateBPM : TDateTime; | |
published | |
property ProjID : Int64 read fProjID write fProjID; | |
property DoneOn : TDateTime read fDoneOn write fDoneOn; | |
property DoneBy : RawUTF8 read fDoneBy write fDoneBy; | |
property COCNo : RawUTF8 read fCOCNo write fCOCNo; | |
property COCType : RawUTF8 read fCOCType write fCOCType; | |
property SentOn : TDateTime read fSentOn write fSentOn; | |
property SentTo : RawUTF8 read fSentTo write fSentTo; | |
property DateBPM : TDateTime read fDateBPM write fDateBPM; | |
end; | |
procedure Main; | |
var | |
fn : TFileName; | |
i : Integer; | |
rec : TOrmTest; | |
restServer : TRestServerDB; | |
Batch : TRestBatch; | |
s : RawUTF8; | |
begin | |
s := FormatUTF8('Running tests using Synopse mORMot framework %, ' + | |
'compiled with %, against SQLite %, on %, at %.', | |
[SYNOPSE_FRAMEWORK_VERSION, COMPILER_VERSION, SQLite3.libversion, | |
OSVersionText, NowToString]); | |
writeln(s); | |
fn := ChangeFileExt(ParamStr(0), '.db3'); | |
if FileExists(fn) then DeleteFile(fn); | |
restServer := TRestServerDB.CreateWithOwnModel([TOrmTest], fn); | |
try | |
restServer.Server.CreateMissingTables; | |
rec := TOrmTest.Create; | |
Batch := TRestBatch.Create(restServer.Orm, TOrmTest); | |
try | |
for i := 1 to 199 do | |
begin | |
rec.IDValue := i; | |
rec.ProjID := i+i; | |
rec.DoneOn := Now; | |
rec.DoneBy := ''; | |
rec.COCNo := ''; | |
rec.COCType := ''; | |
rec.SentOn := Now; | |
rec.SentTo := ''; | |
rec.DateBPM := Now; | |
rec.CreatedBy := ''; | |
rec.CreatedOn := TimeLogFromDateTime(now); | |
rec.EditedBy := ''; | |
rec.EditedOn := TimeLogFromDateTime(now); | |
rec.Notes := ''; | |
rec.RecStatus := 0; | |
rec.File_Type := ''; | |
rec.File_Ext := ''; | |
rec.File_Name := ''; | |
rec.File_Size := 0; | |
rec.File_Date := Now; | |
rec.File_MD5 := ''; | |
Batch.Add(rec, true, true); | |
end; | |
restServer.Orm.BatchSend(Batch); | |
finally | |
Batch.Free; | |
rec.Free; | |
end; | |
finally | |
restServer.Free; | |
end; | |
end; | |
begin | |
try | |
Main; | |
except | |
on E: Exception do | |
Writeln(E.ClassName, ': ', E.Message); | |
end; | |
ReadLn; | |
end. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment