Options.LongStrings not working in 2.7

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
adroege
Posts: 16
Joined: Tue 07 Apr 2009 16:13
Location: Orlando, FL

Options.LongStrings not working in 2.7

Post by adroege » Fri 29 May 2009 20:19

I've recently updated to UniDAC 2.7 for Delphi 7 (using postgres 8.3). It seems to have caused an issue with code that was working with 2.5. We have the following situation:

Code: Select all

myVar: TStringField
myQuery: TUniQuery

myQuery := TUniQuery.Create(nil);
myQuery.Options.LongStrings := true;
...
myVar := myQuery.FieldByName('somefield') as TStringField;
...
In 2.5, myQuery.FieldByName('somefield') is of type ftString. Now in 2.7, myQuery.FieldByName('somefield') is recognized as type ftMemo. In 2.5, the assignment works fine, but in 2.7, the assignment gives an error stating "Invalid class typecast".

What do I need to do to get this code working again?

Thanks

Plash
Devart Team
Posts: 2844
Joined: Wed 10 May 2006 07:09

Post by Plash » Mon 01 Jun 2009 09:31

In the new version VARCHAR fields with size more that 8000 are always mapped to TMemoField. You can change the field size in the database to use TStringField for this field.

adroege
Posts: 16
Joined: Tue 07 Apr 2009 16:13
Location: Orlando, FL

Post by adroege » Thu 04 Jun 2009 18:36

Changing the database field is not an option for us. We really need this to work as it did in 2.5. Is there something I can change in the UniDac code to allow this to work again? This is a critical issue for us and I need a quick fix for it. Any help would be appreciated.

Thanks

Plash
Devart Team
Posts: 2844
Joined: Wed 10 May 2006 07:09

Post by Plash » Fri 05 Jun 2009 07:01

You can fix this problem in the following way:

- Open the PgClassesUni.pas file and find the TPgSQLTypes.DetectDataType procedure.
- Find the following line in this procedure:

Code: Select all

        if (Length < 255) or (LongStrings and (Length < dsMaxStringSize)) then begin
- Replace this line with the following:

Code: Select all

        if (Length < 255) or (LongStrings and (Length <= High(Word))) then begin

Post Reply