Aurelius and Oracle integers in SQLDirect, ODAC

Aurelius and Oracle integers in SQLDirect, ODAC

When using Aurelius with SQLDirect or ODAC on Oracle databases we encounter the following problem (this issue is not present in dbExpress).
SQLDirect and ODAC datasets return integer fields (Oracle NUMBER(9) field for example) and sequence values as variants which VarType is double (not integer not Int64).
So when you declare your entity as:
  [Entity]
  [Table('DEPARTMENT')]
  [Sequence('SEQ_DEPARTMENT')]
  [Id('FId', TIdGenerator.IdentityOrSequence)]
  TDepartment = class
  private
    [Column('ID', [TColumnProp.Unique, TColumnProp.Required, TColumnProp.NoUpdate])]
    FId: Integer;
    ...
an exception is raised every time you try to map a TDepartment object to a DEPARTMENT table row.

To overcome this obstacle, I have "patched" Aurelius source with this ugly piece of code in Aurelius.Mapping.Explorer.pas (Aurelius version 1.4):

procedure TMappingExplorer.SetValue(Member: TRttiMember; Instance: Pointer;
  Value: TValue);
(* Added by G.E. 20120516 )
var
  rtf: TRttiField;
(
End Added by G.E. 20120516 )
begin
  if Member is TRttiField then  
  begin
    (
Added by G.E. 20120516 )
    rtf := TRttiField(Member);
    if (rtf.FieldType.TypeKind in [tkInteger, tkInt64])
      and (Value.Kind = tkFloat) then
    begin
      Value := Value.FromVariant(Trunc(Value.AsExtended));
    end;
    (
End Added by G.E. 20120516 *)  
    TRttiField(Member).SetValue(Instance, Value);
  end
  else
  if Member is TRttiProperty then
    TRttiProperty(Member).SetValue(Instance, Value)
  else
    Assert(False);
end;  

TMS, I apologize for doing it, but I have already pointed out this problem on http://www.tmssoftware.com/site/blog.asp?post=208 a month ago (the time of Aurelius version 1.3)
but my post was... deleted a week later.

This is a "problem" with Odac and SQLdirect.
ODAC is returning the int64 values as float numbers, not integer values. It was the same problem we had with good old BDE.
Try to find and set a proper setting in ODac that makes it return int64 as integer values. Probably it's

EnableLargeInt=true
Or
EnableIntegers=true

We did that to pass ODAC and SQLDirect in our tests. All the supported databases and components are fully tested and all same tests are performed to all configurations. We considered that configuring ODAC and SQLdirect to behave the way all other components do was the correct way for doing the tests.


I agree with you, this is a "problem" with Odac and SQLdirect.