r18288 - gnucash/trunk/src/backend/dbi - Doubles weren't being loaded properly from sqlite3. Fix that problem by examine more closely
Phil Longstaff
plongstaff at code.gnucash.org
Tue Sep 1 21:47:20 EDT 2009
Author: plongstaff
Date: 2009-09-01 21:47:20 -0400 (Tue, 01 Sep 2009)
New Revision: 18288
Trac: http://svn.gnucash.org/trac/changeset/18288
Modified:
gnucash/trunk/src/backend/dbi/gnc-backend-dbi.c
Log:
Doubles weren't being loaded properly from sqlite3. Fix that problem by examine more closely
the type information returned by libdbi.
Modified: gnucash/trunk/src/backend/dbi/gnc-backend-dbi.c
===================================================================
--- gnucash/trunk/src/backend/dbi/gnc-backend-dbi.c 2009-09-01 19:19:42 UTC (rev 18287)
+++ gnucash/trunk/src/backend/dbi/gnc-backend-dbi.c 2009-09-02 01:47:20 UTC (rev 18288)
@@ -1013,11 +1013,13 @@
{
GncDbiSqlRow* dbi_row = (GncDbiSqlRow*)row;
gushort type;
+ guint attrs;
GValue* value;
time_t time;
struct tm tm_struct;
type = dbi_result_get_field_type( dbi_row->result, col_name );
+ attrs = dbi_result_get_field_attribs( dbi_row->result, col_name );
value = g_new0( GValue, 1 );
g_assert( value != NULL );
@@ -1027,8 +1029,15 @@
g_value_set_int64( value, dbi_result_get_longlong( dbi_row->result, col_name ) );
break;
case DBI_TYPE_DECIMAL:
- (void)g_value_init( value, G_TYPE_DOUBLE );
- g_value_set_double( value, dbi_result_get_double( dbi_row->result, col_name ) );
+ if( (attrs & DBI_DECIMAL_SIZEMASK) == DBI_DECIMAL_SIZE4 ) {
+ (void)g_value_init( value, G_TYPE_FLOAT );
+ g_value_set_float( value, dbi_result_get_float( dbi_row->result, col_name ) );
+ } else if( (attrs & DBI_DECIMAL_SIZEMASK) == DBI_DECIMAL_SIZE8 ) {
+ (void)g_value_init( value, G_TYPE_DOUBLE );
+ g_value_set_double( value, dbi_result_get_double( dbi_row->result, col_name ) );
+ } else {
+ PERR( "Field %s: strange decimal length attrs=%d\n", col_name, attrs );
+ }
break;
case DBI_TYPE_STRING:
(void)g_value_init( value, G_TYPE_STRING );
More information about the gnucash-changes
mailing list