* Removed the limit of 8192 characters on stringfields + test

git-svn-id: trunk@13411 -
This commit is contained in:
joost 2009-07-19 14:12:00 +00:00
parent 34c985cfa6
commit 2762ed5fba
2 changed files with 54 additions and 9 deletions

View File

@ -1018,7 +1018,7 @@ begin
// A size of 0 is allowed, since for example Firebird allows
// a query like: 'select '' as fieldname from table' which
// results in a string with size 0.
If (AValue<0) or (AValue>dsMaxStringSize) Then
If (AValue<0) Then
databaseErrorFmt(SInvalidFieldSize,[AValue])
end;
@ -1092,19 +1092,39 @@ end;
function TStringField.GetValue(var AValue: string): Boolean;
Var Buf, TBuf : TStringFieldBuffer;
DynBuf, TDynBuf : Array of char;
begin
Result:=GetData(@Buf);
If Result then
if DataSize <= dsMaxStringSize then
begin
if transliterate then
Result:=GetData(@Buf);
If Result then
begin
DataSet.Translate(Buf,TBuf,False);
AValue:=TBuf;
if transliterate then
begin
DataSet.Translate(Buf,TBuf,False);
AValue:=TBuf;
end
else
AValue:=Buf
end
else
AValue:=Buf
end
else
begin
SetLength(DynBuf,DataSize);
Result:=GetData(@DynBuf[0]);
If Result then
begin
if transliterate then
begin
SetLength(TDynBuf,DataSize);
DataSet.Translate(@DynBuf[0],@TDynBuf[0],False);
AValue:=pchar(TDynBuf);
end
else
AValue:=pchar(DynBuf);
end
end;
end;
procedure TStringField.SetAsBoolean(AValue: Boolean);
@ -1175,7 +1195,7 @@ begin
// A size of 0 is allowed, since for example Firebird allows
// a query like: 'select '' as fieldname from table' which
// results in a string with size 0.
If (AValue<0) or (AValue>(dsMaxStringSize div 2)) Then
If (AValue<0) Then
databaseErrorFmt(SInvalidFieldSize,[AValue]);
end;

View File

@ -84,6 +84,8 @@ type
procedure TestBCDParamQuery;
procedure TestAggregates;
procedure TestStringLargerThen8192;
// SchemaType tests
procedure TestTableNames;
procedure TestFieldNames;
@ -927,6 +929,29 @@ begin
TSQLDBConnector(DBConnector).Connection.ExecuteDirect('update fpdev set name=''nothing'' where (1=0)');
end;
procedure TTestFieldTypes.TestStringLargerThen8192;
var
s : string;
i : integer;
begin
CreateTableWithFieldType(ftString,'VARCHAR(9000)');
TestFieldDeclaration(ftString,9001);
setlength(s,9000);
for i := 1 to 9000 do
s[i]:=chr((i mod 10)+ord('a'));
TSQLDBConnector(DBConnector).Connection.ExecuteDirect('insert into FPDEV2 (FT) values (''' + s + ''')');
with TSQLDBConnector(DBConnector).Query do
begin
Open;
AssertEquals(s,fields[0].AsString);
close;
end;
end;
procedure TTestFieldTypes.TestTableNames;
var TableList : TStringList;
i : integer;