mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-16 15:59:30 +02:00
* Removed the limit of 8192 characters on stringfields + test
git-svn-id: trunk@13411 -
This commit is contained in:
parent
34c985cfa6
commit
2762ed5fba
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user