Reading bigints written to integer fields in sqlite

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
sandy771
Posts: 194
Joined: Tue 22 May 2007 13:57

Reading bigints written to integer fields in sqlite

Post by sandy771 » Tue 02 Sep 2014 12:57

My problem is related to sqlites relaxed type affinity in that if a integer field is defined as a bigint all is OK. Unfortunately sqlite allows the user to define a field as integer, but will happily store a bigint in the field without any loss. So when I try and read an integer field that contains a value > 32bits into a grid I get an erroneous value displayed.

I have no control over my source datasets, so I cannot ensure that fields are defined correctly therefore I am looking for a way with Devart to get around this.

Is there a way with unidac to force a field to return a type definition of bigint/largeint?

Ideally I would like to force all integer fields to show a defined type of bigint if this is possible.

Cheers

sandy771
Posts: 194
Joined: Tue 22 May 2007 13:57

Re: Reading bigints written to integer fields in sqlite

Post by sandy771 » Tue 02 Sep 2014 18:20

Think I have sorted it - Data Type Mapping in TUniConnection seems to have done the trick

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Reading bigints written to integer fields in sqlite

Post by AlexP » Thu 04 Sep 2014 11:58

Hello,

Glad to see that the issue was resolved. If you have any further questions, feel free to contact us.

sandy771
Posts: 194
Joined: Tue 22 May 2007 13:57

Re: Reading bigints written to integer fields in sqlite

Post by sandy771 » Thu 04 Sep 2014 12:18

Hi Alex

Did you see my longer email regarding a similar problem where the field is defined as a timestamp but the data stored within is a float but representing a mac absolute time (seconds and fractions since 1/1/2001) rather than Julian (days since November 24, 4714 B.C)

I really need to be able to read the underlying float and datatyping does not seem to work for this.

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Reading bigints written to integer fields in sqlite

Post by AlexP » Thu 04 Sep 2014 12:32

To get such date as Float, you should set the NativeDate option to False and use the AsFloat method for the field. If you want to display such float values in the grid, you can use the onGetText event of this field, retrieve the value using the AsFloat method, map it explicitly to string or to date by modifying it as required.

Post Reply