mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Fix CRIT errors when loading owner info in business objects.
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@17926 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
c67b86b470
commit
96fea96847
@ -676,6 +676,7 @@ row_get_value_at_col_name( GncSqlRow* row, const gchar* col_name )
|
|||||||
GncDbiSqlRow* dbi_row = (GncDbiSqlRow*)row;
|
GncDbiSqlRow* dbi_row = (GncDbiSqlRow*)row;
|
||||||
gushort type;
|
gushort type;
|
||||||
GValue* value;
|
GValue* value;
|
||||||
|
long long v64;
|
||||||
gint64 raw_int64_value;
|
gint64 raw_int64_value;
|
||||||
gint raw_int_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 );
|
g_value_init( value, G_TYPE_INT64 );
|
||||||
|
|
||||||
// FIXME: Bug in LibDBI: 64 bit int values returned incorrectly
|
// 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_int64_value = dbi_result_get_longlong( dbi_row->result, col_name );
|
||||||
raw_int_value = dbi_result_get_int( 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 ) {
|
if( raw_int_value < 0 && raw_int64_value > 0 ) {
|
||||||
|
@ -865,8 +865,8 @@ gnc_sql_init_object_handlers( void )
|
|||||||
|
|
||||||
/* ================================================================= */
|
/* ================================================================= */
|
||||||
|
|
||||||
static gint64
|
gint64
|
||||||
get_integer_value( const GValue* value )
|
gnc_sql_get_integer_value( const GValue* value )
|
||||||
{
|
{
|
||||||
g_return_val_if_fail( value != NULL, 0 );
|
g_return_val_if_fail( value != NULL, 0 );
|
||||||
|
|
||||||
@ -1060,7 +1060,7 @@ load_int( const GncSqlBackend* be, GncSqlRow* row,
|
|||||||
if( val == NULL ) {
|
if( val == NULL ) {
|
||||||
int_value = 0;
|
int_value = 0;
|
||||||
} else {
|
} else {
|
||||||
int_value = get_integer_value( val );
|
int_value = gnc_sql_get_integer_value( val );
|
||||||
}
|
}
|
||||||
if( table_row->gobj_param_name != NULL ) {
|
if( table_row->gobj_param_name != NULL ) {
|
||||||
g_object_set( pObject, table_row->gobj_param_name, int_value, 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 );
|
val = gnc_sql_row_get_value_at_col_name( row, table_row->col_name );
|
||||||
if( val != NULL ) {
|
if( val != NULL ) {
|
||||||
i64_value = get_integer_value( val );
|
i64_value = gnc_sql_get_integer_value( val );
|
||||||
}
|
}
|
||||||
(*i64_setter)( pObject, i64_value );
|
(*i64_setter)( pObject, i64_value );
|
||||||
}
|
}
|
||||||
@ -1703,7 +1703,7 @@ load_numeric( const GncSqlBackend* be, GncSqlRow* row,
|
|||||||
isNull = TRUE;
|
isNull = TRUE;
|
||||||
num = 0;
|
num = 0;
|
||||||
} else {
|
} else {
|
||||||
num = get_integer_value( val );
|
num = gnc_sql_get_integer_value( val );
|
||||||
}
|
}
|
||||||
buf = g_strdup_printf( "%s_denom", table_row->col_name );
|
buf = g_strdup_printf( "%s_denom", table_row->col_name );
|
||||||
val = gnc_sql_row_get_value_at_col_name( row, buf );
|
val = gnc_sql_row_get_value_at_col_name( row, buf );
|
||||||
@ -1712,7 +1712,7 @@ load_numeric( const GncSqlBackend* be, GncSqlRow* row,
|
|||||||
isNull = TRUE;
|
isNull = TRUE;
|
||||||
denom = 1;
|
denom = 1;
|
||||||
} else {
|
} else {
|
||||||
denom = get_integer_value( val );
|
denom = gnc_sql_get_integer_value( val );
|
||||||
}
|
}
|
||||||
n = gnc_numeric_create( num, denom );
|
n = gnc_numeric_create( num, denom );
|
||||||
if( !isNull ) {
|
if( !isNull ) {
|
||||||
|
@ -657,7 +657,6 @@ void gnc_sql_init_version_info( GncSqlBackend* be );
|
|||||||
void gnc_sql_finalize_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
|
* 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.
|
* 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,
|
gboolean gnc_sql_commit_standard_item( GncSqlBackend* be, QofInstance* inst, const gchar* tableName,
|
||||||
QofIdTypeConst obj_name, const GncSqlColumnTableEntry* col_table );
|
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 );
|
void _retrieve_guid_( gpointer pObject, gpointer pValue );
|
||||||
|
|
||||||
gpointer gnc_sql_compile_query( QofBackend* pBEnd, QofQuery* pQuery );
|
gpointer gnc_sql_compile_query( QofBackend* pBEnd, QofQuery* pQuery );
|
||||||
|
@ -68,7 +68,7 @@ load_owner( const GncSqlBackend* be, GncSqlRow* row,
|
|||||||
book = be->primary_book;
|
book = be->primary_book;
|
||||||
buf = g_strdup_printf( "%s_type", table_row->col_name );
|
buf = g_strdup_printf( "%s_type", table_row->col_name );
|
||||||
val = gnc_sql_row_get_value_at_col_name( row, buf );
|
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 );
|
g_free( buf );
|
||||||
buf = g_strdup_printf( "%s_guid", table_row->col_name );
|
buf = g_strdup_printf( "%s_guid", table_row->col_name );
|
||||||
val = gnc_sql_row_get_value_at_col_name( row, buf );
|
val = gnc_sql_row_get_value_at_col_name( row, buf );
|
||||||
|
Loading…
Reference in New Issue
Block a user