Can't call locate() using a UInt64 key value

The alpha/beta tester's forum for ZeosLib 7.0.x series

Report problems concerning our Delphi 2009+ version and new Zeoslib 7.0 features here.

This is a forum that will be removed once the 7.X version goes into stable!!

Moderators: gto, EgonHugeist, olehs

Locked
skydvrz
Fresh Boarder
Fresh Boarder
Posts: 13
Joined: 15.12.2005, 22:56
Location: Olympia, WA USA
Contact:

Can't call locate() using a UInt64 key value

Post by skydvrz »

This code never finds the requested record, even if the record exists:

Code: Select all

PROCEDURE TMainForm.ActivateOffender(OID : UInt64);
BEGIN
    ejDM.dsOffender.DataSet.Locate('id', OID, []);
END;
The reason is that ZVariant has no case for UInt64 values. It can handle In64 though.

I modified DecodeVariant like so, and Locate() started to work again:

Code: Select all

{**
  Decodes a standard variant value into custom variant.
  @param Value a standard variant value to be decoded.
  @returns an decoded custom variant.
}
function DecodeVariant(const Value: Variant): TZVariant;
begin
  case VarType(Value) of
    varSmallint, varInteger, varByte:
      DefVarManager.SetAsInteger(Result, Integer(Value));
    varBoolean: DefVarManager.SetAsBoolean(Result, Value);
    varString:
      DefVarManager.SetAsString(Result, Value);
   {$IFDEF DELPHI12_UP}
   varUString:
      DefVarManager.SetAsUnicodeString(Result, Value);
   {$ENDIF}
    varSingle, varDouble, varCurrency:
      DefVarManager.SetAsFloat(Result, Value);
    varUnknown: DefVarManager.SetAsInterface(Result, Value);
    varOleStr:
      DefVarManager.SetAsUnicodeString(Result, Value);
    varDate: DefVarManager.SetAsDateTime(Result, Value);
    varShortInt, varWord, varLongWord:
      DefVarManager.SetAsInteger(Result, Value);
    varInt64,varUInt64: // KGM - added varUInt64 case
      DefVarManager.SetAsInteger(Result, Value);
  else
    DefVarManager.SetNull(Result);
  end;
end;
Note that my fix will fail if the UInt64 value exceeds $7FFFFFFFFFFFFFFF

so... a more elegant fix is probably necessary, but at least DecodeVariant will stop setting my ^&#@$!! value to NULL! :shock:

MySQL uses unsigned 64 bit Ints for autoincrement fields.

Best regards,

Kevin G. McCoy
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post by mdaems »

I applied your change in Testing branch. I had to add

Code: Select all

{$IFDEF BDS5_UP},varUInt64{$ENDIF}
.

Mark
Image
skydvrz
Fresh Boarder
Fresh Boarder
Posts: 13
Joined: 15.12.2005, 22:56
Location: Olympia, WA USA
Contact:

Post by skydvrz »

Thanks Mark!
Locked