mirror of
https://github.com/danieleteti/delphimvcframework.git
synced 2024-11-16 00:05:53 +01:00
Added unit test for time/date types in RQL query
This commit is contained in:
parent
4dd2c86bdf
commit
d883f87fb5
@ -62,6 +62,8 @@ type
|
|||||||
[Test]
|
[Test]
|
||||||
procedure TestRQL;
|
procedure TestRQL;
|
||||||
[Test]
|
[Test]
|
||||||
|
procedure TestRQLWithDateTime;
|
||||||
|
[Test]
|
||||||
procedure TestRQLLimit;
|
procedure TestRQLLimit;
|
||||||
[Test]
|
[Test]
|
||||||
procedure TestIssue424;
|
procedure TestIssue424;
|
||||||
@ -123,6 +125,7 @@ const
|
|||||||
|
|
||||||
var
|
var
|
||||||
GDBFileName: string = '';
|
GDBFileName: string = '';
|
||||||
|
SQLiteFileName: string = 'sqlitetest.db';
|
||||||
GDBTemplateFileName: string = '';
|
GDBTemplateFileName: string = '';
|
||||||
GPGIsInitialized: boolean = false;
|
GPGIsInitialized: boolean = false;
|
||||||
|
|
||||||
@ -142,8 +145,8 @@ var
|
|||||||
begin
|
begin
|
||||||
LParams := TStringList.Create;
|
LParams := TStringList.Create;
|
||||||
try
|
try
|
||||||
GDBFileName := TPath.Combine(TPath.GetDirectoryName(ParamStr(0)), 'sqlitetest.db');
|
SQLiteFileName := TPath.Combine(TPath.GetDirectoryName(ParamStr(0)), SQLiteFileName);
|
||||||
LParams.Add('Database=' + GDBFileName);
|
LParams.Add('Database=' + SQLiteFileName);
|
||||||
LParams.Add('OpenMode=CreateUTF8');
|
LParams.Add('OpenMode=CreateUTF8');
|
||||||
if AIsPooled then
|
if AIsPooled then
|
||||||
begin
|
begin
|
||||||
@ -550,6 +553,26 @@ begin
|
|||||||
Assert.AreEqual(Int64(0), TMVCActiveRecord.Count<TCustomer>(RQL1));
|
Assert.AreEqual(Int64(0), TMVCActiveRecord.Count<TCustomer>(RQL1));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TTestActiveRecordBase.TestRQLWithDateTime;
|
||||||
|
var
|
||||||
|
lCustomers: TObjectList<TCustomer>;
|
||||||
|
const
|
||||||
|
RQL1 = 'and(and(gt(CreationDate, "2010-10-01"),le(CreationDate, "2022-12-31")),' +
|
||||||
|
'and(gt(CreationTime, "00:00:00"),le(CreationTime, "08:00:00")))';
|
||||||
|
begin
|
||||||
|
TMVCActiveRecord.DeleteAll(TCustomer);
|
||||||
|
Assert.AreEqual(Int64(0), TMVCActiveRecord.Count(TCustomer));
|
||||||
|
LoadData;
|
||||||
|
lCustomers := TMVCActiveRecord.SelectRQL<TCustomer>(RQL1, MAXINT);
|
||||||
|
try
|
||||||
|
Assert.AreEqual(140, lCustomers.Count);
|
||||||
|
finally
|
||||||
|
lCustomers.Free;
|
||||||
|
end;
|
||||||
|
TMVCActiveRecord.DeleteRQL(TCustomer, RQL1);
|
||||||
|
Assert.AreEqual(Int64(0), TMVCActiveRecord.Count<TCustomer>(RQL1));
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TTestActiveRecordBase.TestSelectWithExceptions;
|
procedure TTestActiveRecordBase.TestSelectWithExceptions;
|
||||||
var
|
var
|
||||||
lCustomer: TCustomer;
|
lCustomer: TCustomer;
|
||||||
@ -676,6 +699,8 @@ begin
|
|||||||
Format('%s %s %s', [lCustomer.City, Stuff[Random(high(Stuff) + 1)],
|
Format('%s %s %s', [lCustomer.City, Stuff[Random(high(Stuff) + 1)],
|
||||||
CompanySuffix[Random(high(CompanySuffix) + 1)]]);
|
CompanySuffix[Random(high(CompanySuffix) + 1)]]);
|
||||||
lCustomer.Note := Stuff[I mod Length(Stuff)];
|
lCustomer.Note := Stuff[I mod Length(Stuff)];
|
||||||
|
lCustomer.CreationTime := EncodeTime(I mod 23, I, 60 - 1, 0);
|
||||||
|
lCustomer.CreationDate := EncodeDate(2020 - I, (I mod 12) + 1, (I mod 27) + 1);
|
||||||
lCustomer.Insert;
|
lCustomer.Insert;
|
||||||
finally
|
finally
|
||||||
lCustomer.Free;
|
lCustomer.Free;
|
||||||
@ -704,9 +729,9 @@ begin
|
|||||||
if FDManager.ConnectionDefs.FindConnectionDef(fConDefName) = nil then
|
if FDManager.ConnectionDefs.FindConnectionDef(fConDefName) = nil then
|
||||||
begin
|
begin
|
||||||
CreatePrivateConnDef(True);
|
CreatePrivateConnDef(True);
|
||||||
if TFile.Exists(GDBFileName) then
|
if TFile.Exists(SQLiteFileName) then
|
||||||
begin
|
begin
|
||||||
TFile.Delete(GDBFileName);
|
TFile.Delete(SQLiteFileName);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
fConnection.Open;
|
fConnection.Open;
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
<ProjectVersion>19.1</ProjectVersion>
|
<ProjectVersion>19.1</ProjectVersion>
|
||||||
<FrameworkType>VCL</FrameworkType>
|
<FrameworkType>VCL</FrameworkType>
|
||||||
<Base>True</Base>
|
<Base>True</Base>
|
||||||
<Config Condition="'$(Config)'==''">CONSOLE</Config>
|
<Config Condition="'$(Config)'==''">GUI</Config>
|
||||||
<Platform Condition="'$(Platform)'==''">Win32</Platform>
|
<Platform Condition="'$(Platform)'==''">Win32</Platform>
|
||||||
<TargetedPlatforms>1</TargetedPlatforms>
|
<TargetedPlatforms>1</TargetedPlatforms>
|
||||||
<AppType>Console</AppType>
|
<AppType>Console</AppType>
|
||||||
|
@ -1,3 +1,27 @@
|
|||||||
|
// ***************************************************************************
|
||||||
|
//
|
||||||
|
// Delphi MVC Framework
|
||||||
|
//
|
||||||
|
// Copyright (c) 2010-2020 Daniele Teti and the DMVCFramework Team
|
||||||
|
//
|
||||||
|
// https://github.com/danieleteti/delphimvcframework
|
||||||
|
//
|
||||||
|
// ***************************************************************************
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
//
|
||||||
|
// *************************************************************************** }
|
||||||
|
|
||||||
unit PGUtilsU;
|
unit PGUtilsU;
|
||||||
|
|
||||||
interface
|
interface
|
||||||
|
Loading…
Reference in New Issue
Block a user