diff --git a/src/backend/dbi/gnc-backend-dbi.c b/src/backend/dbi/gnc-backend-dbi.c index 97778066d7..9e42faf13f 100644 --- a/src/backend/dbi/gnc-backend-dbi.c +++ b/src/backend/dbi/gnc-backend-dbi.c @@ -676,6 +676,7 @@ row_get_value_at_col_name( GncSqlRow* row, const gchar* col_name ) GncDbiSqlRow* dbi_row = (GncDbiSqlRow*)row; gushort type; GValue* value; + long long v64; gint64 raw_int64_value; gint raw_int_value; @@ -686,6 +687,7 @@ row_get_value_at_col_name( GncSqlRow* row, const gchar* col_name ) g_value_init( value, G_TYPE_INT64 ); // FIXME: Bug in LibDBI: 64 bit int values returned incorrectly + v64 = dbi_result_get_longlong( dbi_row->result, col_name ); raw_int64_value = dbi_result_get_longlong( dbi_row->result, col_name ); raw_int_value = dbi_result_get_int( dbi_row->result, col_name ); if( raw_int_value < 0 && raw_int64_value > 0 ) { diff --git a/src/backend/sql/gnc-backend-sql.c b/src/backend/sql/gnc-backend-sql.c index dffa430786..0e312545aa 100644 --- a/src/backend/sql/gnc-backend-sql.c +++ b/src/backend/sql/gnc-backend-sql.c @@ -865,8 +865,8 @@ gnc_sql_init_object_handlers( void ) /* ================================================================= */ -static gint64 -get_integer_value( const GValue* value ) +gint64 +gnc_sql_get_integer_value( const GValue* value ) { g_return_val_if_fail( value != NULL, 0 ); @@ -1060,7 +1060,7 @@ load_int( const GncSqlBackend* be, GncSqlRow* row, if( val == NULL ) { int_value = 0; } else { - int_value = get_integer_value( val ); + int_value = gnc_sql_get_integer_value( val ); } if( table_row->gobj_param_name != NULL ) { g_object_set( pObject, table_row->gobj_param_name, int_value, NULL ); @@ -1219,7 +1219,7 @@ load_int64( const GncSqlBackend* be, GncSqlRow* row, val = gnc_sql_row_get_value_at_col_name( row, table_row->col_name ); if( val != NULL ) { - i64_value = get_integer_value( val ); + i64_value = gnc_sql_get_integer_value( val ); } (*i64_setter)( pObject, i64_value ); } @@ -1703,7 +1703,7 @@ load_numeric( const GncSqlBackend* be, GncSqlRow* row, isNull = TRUE; num = 0; } else { - num = get_integer_value( val ); + num = gnc_sql_get_integer_value( val ); } buf = g_strdup_printf( "%s_denom", table_row->col_name ); val = gnc_sql_row_get_value_at_col_name( row, buf ); @@ -1712,7 +1712,7 @@ load_numeric( const GncSqlBackend* be, GncSqlRow* row, isNull = TRUE; denom = 1; } else { - denom = get_integer_value( val ); + denom = gnc_sql_get_integer_value( val ); } n = gnc_numeric_create( num, denom ); if( !isNull ) { diff --git a/src/backend/sql/gnc-backend-sql.h b/src/backend/sql/gnc-backend-sql.h index bb90ad51e6..a30c8e25f1 100644 --- a/src/backend/sql/gnc-backend-sql.h +++ b/src/backend/sql/gnc-backend-sql.h @@ -657,7 +657,6 @@ void gnc_sql_init_version_info( GncSqlBackend* be ); void gnc_sql_finalize_version_info( GncSqlBackend* be ); /** - * * Commits a "standard" item to the database. In most cases, a commit of one object vs * another differs only in the table name and column table. * @@ -671,6 +670,14 @@ void gnc_sql_finalize_version_info( GncSqlBackend* be ); gboolean gnc_sql_commit_standard_item( GncSqlBackend* be, QofInstance* inst, const gchar* tableName, QofIdTypeConst obj_name, const GncSqlColumnTableEntry* col_table ); +/** + * Gets an integer value (of any size) from a GValue. + * + * @param value Source value + * @return Integer value + */ +gint64 gnc_sql_get_integer_value( const GValue* value ); + void _retrieve_guid_( gpointer pObject, gpointer pValue ); gpointer gnc_sql_compile_query( QofBackend* pBEnd, QofQuery* pQuery ); diff --git a/src/business/business-core/sql/gnc-owner-sql.c b/src/business/business-core/sql/gnc-owner-sql.c index 7c6d7cda77..8dc9409e6c 100644 --- a/src/business/business-core/sql/gnc-owner-sql.c +++ b/src/business/business-core/sql/gnc-owner-sql.c @@ -68,7 +68,7 @@ load_owner( const GncSqlBackend* be, GncSqlRow* row, book = be->primary_book; buf = g_strdup_printf( "%s_type", table_row->col_name ); val = gnc_sql_row_get_value_at_col_name( row, buf ); - type = (GncOwnerType)g_value_get_int( val ); + type = (GncOwnerType)gnc_sql_get_integer_value( val ); g_free( buf ); buf = g_strdup_printf( "%s_guid", table_row->col_name ); val = gnc_sql_row_get_value_at_col_name( row, buf );