mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-11 22:06:40 +02:00
* TDateTimeField.SetAsString now sets the field to NULL if an empty string is provided, bug #12875 + testsuite test
git-svn-id: trunk@12455 -
This commit is contained in:
parent
00e76eab6a
commit
e89b30abef
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -7660,6 +7660,7 @@ tests/test/packages/fcl-db/assertions.pas svneol=native#text/plain
|
|||||||
tests/test/packages/fcl-db/dbftoolsunit.pas svneol=native#text/plain
|
tests/test/packages/fcl-db/dbftoolsunit.pas svneol=native#text/plain
|
||||||
tests/test/packages/fcl-db/tdb1.pp svneol=native#text/plain
|
tests/test/packages/fcl-db/tdb1.pp svneol=native#text/plain
|
||||||
tests/test/packages/fcl-db/tdb2.pp svneol=native#text/plain
|
tests/test/packages/fcl-db/tdb2.pp svneol=native#text/plain
|
||||||
|
tests/test/packages/fcl-db/tdb3.pp svneol=native#text/plain
|
||||||
tests/test/packages/fcl-db/toolsunit.pas svneol=native#text/plain
|
tests/test/packages/fcl-db/toolsunit.pas svneol=native#text/plain
|
||||||
tests/test/packages/fcl-registry/tregistry1.pp svneol=native#text/plain
|
tests/test/packages/fcl-registry/tregistry1.pp svneol=native#text/plain
|
||||||
tests/test/packages/hash/tmdtest.pp svneol=native#text/plain
|
tests/test/packages/hash/tmdtest.pp svneol=native#text/plain
|
||||||
|
@ -2034,8 +2034,13 @@ procedure TDateTimeField.SetAsString(const AValue: string);
|
|||||||
Var R : TDateTime;
|
Var R : TDateTime;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
R:=StrToDateTime(AVAlue);
|
if AValue<>'' then
|
||||||
SetData(@R,False);
|
begin
|
||||||
|
R:=StrToDateTime(AVAlue);
|
||||||
|
SetData(@R,False);
|
||||||
|
end
|
||||||
|
else
|
||||||
|
SetData(Nil);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
50
tests/test/packages/fcl-db/tdb3.pp
Normal file
50
tests/test/packages/fcl-db/tdb3.pp
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
program tdb3;
|
||||||
|
// Test for bug 12875
|
||||||
|
{$mode objfpc}{$H+}
|
||||||
|
|
||||||
|
uses
|
||||||
|
Classes, SysUtils, dbf, db;
|
||||||
|
|
||||||
|
var
|
||||||
|
Db1: TDbf;
|
||||||
|
DateFloat: Double;
|
||||||
|
DateStr: String;
|
||||||
|
begin
|
||||||
|
Db1 := TDbf.Create(nil);
|
||||||
|
Db1.FilePathFull := ExtractFilePath(ParamStr(0));
|
||||||
|
Db1.TableName := 'testdatestr.dbf';
|
||||||
|
if not FileExists(Db1.TableName) then
|
||||||
|
begin
|
||||||
|
Db1.FieldDefs.Add('DateField', ftDate);
|
||||||
|
Db1.CreateTable;
|
||||||
|
end;
|
||||||
|
|
||||||
|
Db1.Open;
|
||||||
|
Db1.Append;
|
||||||
|
Db1.Post;
|
||||||
|
|
||||||
|
DateStr := Db1.FieldByName('DateField').AsString;
|
||||||
|
DateFloat := Db1.FieldByName('DateField').AsFloat;
|
||||||
|
if DateFloat<>0 then Halt(1);
|
||||||
|
WriteLn('DateStr: "', DateStr, '" DateFloat: ', DateFloat);
|
||||||
|
|
||||||
|
Db1.Edit;
|
||||||
|
Db1.FieldByName('DateField').AsDateTime := Date;
|
||||||
|
Db1.Post;
|
||||||
|
DateStr := Db1.FieldByName('DateField').AsString;
|
||||||
|
DateFloat := Db1.FieldByName('DateField').AsFloat;
|
||||||
|
WriteLn('DateStr: "', DateStr, '" DateFloat: ', DateFloat);
|
||||||
|
|
||||||
|
Db1.Edit;
|
||||||
|
Db1.FieldByName('DateField').AsString := '';
|
||||||
|
Db1.Post;
|
||||||
|
DateStr := Db1.FieldByName('DateField').AsString;
|
||||||
|
DateFloat := Db1.FieldByName('DateField').AsFloat;
|
||||||
|
WriteLn('DateStr: "', DateStr, '" DateFloat: ', DateFloat);
|
||||||
|
if not Db1.FieldByName('DateField').IsNull then Halt(1);
|
||||||
|
if DateFloat<>0 then Halt(1);
|
||||||
|
|
||||||
|
Db1.Free;
|
||||||
|
end.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user