Skip to content

Commit fef838a

Browse files
committed
[+] fill qryChains.FieldDefs
[-] remove duplicate for `max_instances` from `qryChains.SQL` [-] remove obsolete `task_id` from `qryChains.SQL` [*] set default value for `timeout` to 0 [*] use `GetBookmark()`/`GotoBookmark()` instead of `Locate()` in `qryAfterPost()`
1 parent 3f81678 commit fef838a

2 files changed

Lines changed: 54 additions & 15 deletions

File tree

udatamodule.lfm

Lines changed: 50 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,52 @@ object dmPgEngine: TdmPgEngine
2828
PacketRecords = -1
2929
IndexName = 'DEFAULT_ORDER'
3030
MaxIndexesCount = 20
31-
FieldDefs = <>
31+
FieldDefs = <
32+
item
33+
Name = 'chain_id'
34+
DataType = ftLargeint
35+
Precision = -1
36+
end
37+
item
38+
Name = 'chain_name'
39+
DataType = ftWideString
40+
Precision = -1
41+
end
42+
item
43+
Name = 'run_at'
44+
DataType = ftMemo
45+
Precision = -1
46+
end
47+
item
48+
Name = 'max_instances'
49+
DataType = ftInteger
50+
Precision = -1
51+
end
52+
item
53+
Name = 'live'
54+
DataType = ftBoolean
55+
Precision = -1
56+
end
57+
item
58+
Name = 'self_destruct'
59+
DataType = ftBoolean
60+
Precision = -1
61+
end
62+
item
63+
Name = 'exclusive_execution'
64+
DataType = ftBoolean
65+
Precision = -1
66+
end
67+
item
68+
Name = 'client_name'
69+
DataType = ftMemo
70+
Precision = -1
71+
end
72+
item
73+
Name = 'timeout'
74+
DataType = ftInteger
75+
Precision = -1
76+
end>
3277
AfterClose = qryChainsAfterClose
3378
AfterDelete = qryChainsAfterDelete
3479
AfterInsert = qryChainsAfterInsert
@@ -46,32 +91,29 @@ object dmPgEngine: TdmPgEngine
4691
' self_destruct,'
4792
' exclusive_execution,'
4893
' client_name,'
49-
' timeout,'
50-
' max_instances'
94+
' timeout'
5195
'FROM timetable.chain'
5296
'ORDER BY chain_id'
5397
)
5498
InsertSQL.Strings = (
5599
'INSERT INTO timetable.chain ('
56-
#9'"task_id",'
57100
#9'"chain_name",'
58101
#9'"run_at",'
59102
#9'"max_instances",'
60103
#9'"live",'
61104
#9'"self_destruct",'
62105
#9'"exclusive_execution",'
63106
#9'"client_name",'
64-
' "timeout"'
107+
#9'"timeout"'
65108
') VALUES ('
66-
#9'timetable.add_task(''SQL'', ''SELECT 1'', NULL),'
67109
#9':"chain_name",'
68110
#9':"run_at",'
69111
#9':"max_instances",'
70112
#9':"live",'
71113
#9':"self_destruct",'
72114
#9':"exclusive_execution",'
73115
#9':"client_name",'
74-
' :"timeout"'
116+
#9':"timeout"'
75117
')'
76118
)
77119
UpdateSQL.Strings = (
@@ -164,7 +206,7 @@ object dmPgEngine: TdmPgEngine
164206
)
165207
UpdateSQL.Strings = (
166208
'UPDATE timetable.task SET ('
167-
' task_oder,'
209+
' task_order,'
168210
' task_name,'
169211
' command,'
170212
' kind,'

udatamodule.pas

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -91,21 +91,18 @@ procedure TdmPgEngine.qryChainsAfterInsert(DataSet: TDataSet);
9191
FieldByName('self_destruct').AsBoolean := False;
9292
FieldByName('exclusive_execution').AsBoolean := False;
9393
FieldByName('run_at').AsString := '* * * * *';
94+
FieldByName('timeout').AsInteger := 0;
9495
end;
9596
end;
9697

9798
procedure TdmPgEngine.qryAfterPost(DataSet: TDataSet);
9899
var
99-
FldVal: variant;
100-
FldName: string;
100+
B: TBookmark;
101101
Q: TSQLQuery;
102-
const
103-
FldNames: array[boolean] of string = ('chain_name', 'task_id');
104102
begin
105103
Q := DataSet as TSQLQuery;
106-
FldName := FldNames[Q = qryTasks];
107104
Q.IndexName := '';
108-
FldVal := DataSet.FieldValues[FldName];
105+
B := DataSet.GetBookmark;
109106
try
110107
Q.ApplyUpdates;
111108
DataSet.Refresh;
@@ -116,7 +113,7 @@ procedure TdmPgEngine.qryAfterPost(DataSet: TDataSet);
116113
Q.CancelUpdates;
117114
end;
118115
end;
119-
DataSet.Locate(FldName, FldVal, []);
116+
DataSet.GotoBookmark(B);
120117
if Q = qryChains then
121118
fmMain.MainForm.UpdateSortIndication(nil);
122119
end;

0 commit comments

Comments
 (0)