r17309 - gnucash/branches/gda-dev2 - 1) Use the 'infant' flag in the qof instance. If set, don't try to see if

Phil Longstaff plongstaff at cvs.gnucash.org
Fri Jul 11 23:12:25 EDT 2008


Author: plongstaff
Date: 2008-07-11 23:12:24 -0400 (Fri, 11 Jul 2008)
New Revision: 17309
Trac: http://svn.gnucash.org/trac/changeset/17309

Removed:
   gnucash/branches/gda-dev2/GNOME2_STATUS
Modified:
   gnucash/branches/gda-dev2/GDA_STATUS
   gnucash/branches/gda-dev2/src/backend/sql/gnc-account-sql.c
   gnucash/branches/gda-dev2/src/backend/sql/gnc-backend-sql.c
   gnucash/branches/gda-dev2/src/backend/sql/gnc-book-sql.c
   gnucash/branches/gda-dev2/src/backend/sql/gnc-budget-sql.c
   gnucash/branches/gda-dev2/src/backend/sql/gnc-commodity-sql.c
   gnucash/branches/gda-dev2/src/backend/sql/gnc-lots-sql.c
   gnucash/branches/gda-dev2/src/backend/sql/gnc-price-sql.c
   gnucash/branches/gda-dev2/src/backend/sql/gnc-schedxaction-sql.c
   gnucash/branches/gda-dev2/src/backend/sql/gnc-slots-sql.c
   gnucash/branches/gda-dev2/src/backend/sql/gnc-slots-sql.h
   gnucash/branches/gda-dev2/src/backend/sql/gnc-transaction-sql.c
   gnucash/branches/gda-dev2/src/business/business-core/sql/gnc-bill-term-sql.c
   gnucash/branches/gda-dev2/src/business/business-core/sql/gnc-customer-sql.c
   gnucash/branches/gda-dev2/src/business/business-core/sql/gnc-employee-sql.c
   gnucash/branches/gda-dev2/src/business/business-core/sql/gnc-entry-sql.c
   gnucash/branches/gda-dev2/src/business/business-core/sql/gnc-invoice-sql.c
   gnucash/branches/gda-dev2/src/business/business-core/sql/gnc-job-sql.c
   gnucash/branches/gda-dev2/src/business/business-core/sql/gnc-order-sql.c
   gnucash/branches/gda-dev2/src/business/business-core/sql/gnc-tax-table-sql.c
   gnucash/branches/gda-dev2/src/business/business-core/sql/gnc-vendor-sql.c
Log:
1) Use the 'infant' flag in the qof instance.  If set, don't try to see if
the object already exists.  This saves a number of db queries and operations.
2) Remove obsolete GNOME2_STATUS
3) Update GDA_STATUS



Modified: gnucash/branches/gda-dev2/GDA_STATUS
===================================================================
--- gnucash/branches/gda-dev2/GDA_STATUS	2008-07-12 01:12:57 UTC (rev 17308)
+++ gnucash/branches/gda-dev2/GDA_STATUS	2008-07-12 03:12:24 UTC (rev 17309)
@@ -1,31 +1,28 @@
 Status of the GDA backend.
 
-Code for all standard and business objects has been written.  The branch has been
-merged with the trunk through rev 17070.  The following bugs/issues are known.
+Code for all standard and business objects has been written.  The branch has
+been merged with the trunk through rev 17070.  The following bugs/issues are
+known.
 
-* Transactions are saved with dates at 00:00:00 o'clock.  This often/usually has
-the result that the transactions are shown on the day before they were entered (I
-am at TZ -0500).
-* When saving from another file, the billterms table is not created/saved.  Instead,
-it will be created when the file is next opened. (libgda bug 527923)
-* Initial save performance is better than it used to be, but is still slow.  For
-example, saving my file with ~8000 transactions and ~21000 splits takes 13 minutes
-to an sqlite db.
-* The 'Database Connection' action (File menu) should see if the db already exists
-and should allow the user to connect to and open an existing file, not always
-overwrite it.
+* Initial save performance is better than it used to be, but is still slow.
+For example, saving my file with ~8000 transactions and ~21000 splits takes
+13 minutes to an sqlite db.
 * Foreign key definitions should be used for referential integrity.
-* The db should contain some indication of its schema version number.  When opening
-a db, gnucash should see if the schema is up to date, and should update it if it
-isn't.
-* (Maybe) Keep an 'old values' table for each main table.  When a record is updated,
-copy the old record to the 'old values' table first to keep track of any changes.
+* The db should contain some indication of its schema version number.  When
+opening a db, gnucash should see if the schema is up to date, and should
+update it if it isn't.
+* (Maybe) Keep an 'old values' table for each main table.  When a record is
+updated, copy the old record to the 'old values' table first to keep track of
+any changes.
 * Use prepared statements
 * Use cursor-based data models when reading from the db for better performance
 * Write automated tests
 * Write doxygen comment headers
 * Don't need a log file
-* Certain dialogs create an object when opened and update it as they go along. This
-can result in trying to save invalid objects:
+* Certain dialogs create an object when opened and update it as they go along.
+This can result in trying to save invalid objects:
 	- Price editor (new price has no commodity or currency)
 	- New invoice
+* Use the "infant" flag to avoid checking whether a new object is already in
+the db.
+* Need transactions to group updates to multiple objects

Deleted: gnucash/branches/gda-dev2/GNOME2_STATUS
===================================================================
--- gnucash/branches/gda-dev2/GNOME2_STATUS	2008-07-12 01:12:57 UTC (rev 17308)
+++ gnucash/branches/gda-dev2/GNOME2_STATUS	2008-07-12 03:12:24 UTC (rev 17309)
@@ -1,9 +0,0 @@
-# -*- rst -*-
-
-Intro
------
-This was a list of items specifically not functioning in the gnome-2 port.
-It outgrew that, and became a list of bugs.  Now, it more simply lives in
-bugzilla. 
-
-http://bugzilla.gnome.org/buglist.cgi?query_format=advanced&short_desc_type=allwordssubstr&short_desc=&product=GnuCash&version=SVN&long_desc_type=substring&long_desc=&status_whiteboard_type=allwordssubstr&status_whiteboard=&keywords_type=allwords&keywords=&bug_status=UNCONFIRMED&bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED&bug_status=NEEDINFO&emailassigned_to1=1&emailtype1=substring&email1=&emailassigned_to2=1&emailreporter2=1&emailqa_contact2=1&emailcc2=1&emailtype2=substring&email2=&bugidtype=include&bug_id=&chfieldfrom=&chfieldto=Now&chfieldvalue=&cmdtype=doit&order=Reuse+same+sort+as+last+time&field0-0-0=noop&type0-0-0=noop&value0-0-0=

Modified: gnucash/branches/gda-dev2/src/backend/sql/gnc-account-sql.c
===================================================================
--- gnucash/branches/gda-dev2/src/backend/sql/gnc-account-sql.c	2008-07-12 01:12:57 UTC (rev 17308)
+++ gnucash/branches/gda-dev2/src/backend/sql/gnc-account-sql.c	2008-07-12 03:12:24 UTC (rev 17309)
@@ -268,14 +268,18 @@
 {
     Account* pAcc = GNC_ACCOUNT(inst);
     const GUID* guid;
+	gboolean is_infant;
 
 	g_return_if_fail( be != NULL );
 	g_return_if_fail( inst != NULL );
 	g_return_if_fail( GNC_IS_ACCOUNT(inst) );
 
-    // If there is no commodity yet, this might be because a new account name has been entered directly
-    // into the register and an account window will be opened.  The account info is not complete yet,
-    // but the name has been set, triggering this commit
+	is_infant = qof_instance_get_infant( inst );
+
+    // If there is no commodity yet, this might be because a new account name
+	// has been entered directly into the register and an account window will
+	// be opened.  The account info is not complete yet, but the name has been
+	// set, triggering this commit
     if( xaccAccountGetCommodity( pAcc ) != NULL ) {
 		gint op;
 
@@ -284,7 +288,7 @@
 
 		if( qof_instance_get_destroying( inst ) ) {
 			op = OP_DB_DELETE;
-		} else if( be->is_pristine_db ) {
+		} else if( be->is_pristine_db || is_infant ) {
 			op = OP_DB_ADD;
 		} else {
 			op = OP_DB_ADD_OR_UPDATE;
@@ -295,7 +299,7 @@
         // Now, commit or delete any slots
         guid = qof_instance_get_guid( inst );
         if( !qof_instance_get_destroying(inst) ) {
-            gnc_sql_slots_save( be, guid, qof_instance_get_slots( inst ) );
+            gnc_sql_slots_save( be, guid, is_infant, qof_instance_get_slots( inst ) );
         } else {
             gnc_sql_slots_delete( be, guid );
         }

Modified: gnucash/branches/gda-dev2/src/backend/sql/gnc-backend-sql.c
===================================================================
--- gnucash/branches/gda-dev2/src/backend/sql/gnc-backend-sql.c	2008-07-12 01:12:57 UTC (rev 17308)
+++ gnucash/branches/gda-dev2/src/backend/sql/gnc-backend-sql.c	2008-07-12 03:12:24 UTC (rev 17309)
@@ -476,6 +476,7 @@
 	gboolean status;
 	gboolean is_dirty;
 	gboolean is_destroying;
+	gboolean is_infant;
 
 	g_return_if_fail( be != NULL );
 	g_return_if_fail( inst != NULL );
@@ -498,17 +499,12 @@
 
 	is_dirty = qof_instance_get_dirty_flag( inst );
 	is_destroying = qof_instance_get_destroying( inst );
+	is_infant = qof_instance_get_infant( inst );
 
-    DEBUG( "%s dirty = %d, do_free = %d\n",
+    DEBUG( "%s dirty = %d, do_free = %d, infant = %d\n",
              (inst->e_type ? inst->e_type : "(null)"),
-             is_dirty, is_destroying );
+             is_dirty, is_destroying, is_infant );
 
-#if 0
-    if( !is_dirty && !is_destroying && GNC_IS_TRANS(inst) ) {
-        gnc_sql_transaction_commit_splits( be, GNC_TRANS(inst) );
-    }
-#endif
-
     if( !is_dirty && !is_destroying ) {
 		LEAVE( "!dirty OR !destroying" );
 		return;

Modified: gnucash/branches/gda-dev2/src/backend/sql/gnc-book-sql.c
===================================================================
--- gnucash/branches/gda-dev2/src/backend/sql/gnc-book-sql.c	2008-07-12 01:12:57 UTC (rev 17308)
+++ gnucash/branches/gda-dev2/src/backend/sql/gnc-book-sql.c	2008-07-12 03:12:24 UTC (rev 17309)
@@ -195,14 +195,16 @@
 {
     const GUID* guid;
 	gint op;
+	gboolean is_infant;
 
 	g_return_if_fail( be != NULL );
 	g_return_if_fail( inst != NULL );
 	g_return_if_fail( QOF_IS_BOOK(inst) );
 
+	is_infant = qof_instance_get_infant( inst );
 	if( qof_instance_get_destroying( inst ) ) {
 		op = OP_DB_DELETE;
-	} else if( be->is_pristine_db ) {
+	} else if( be->is_pristine_db || is_infant ) {
 		op = OP_DB_ADD;
 	} else {
 		op = OP_DB_ADD_OR_UPDATE;
@@ -214,7 +216,7 @@
 
     // Now, commit any slots
     if( !qof_instance_get_destroying(inst) ) {
-        gnc_sql_slots_save( be, guid, qof_instance_get_slots( inst ) );
+        gnc_sql_slots_save( be, guid, is_infant, qof_instance_get_slots( inst ) );
     } else {
         gnc_sql_slots_delete( be, guid );
     }

Modified: gnucash/branches/gda-dev2/src/backend/sql/gnc-budget-sql.c
===================================================================
--- gnucash/branches/gda-dev2/src/backend/sql/gnc-budget-sql.c	2008-07-12 01:12:57 UTC (rev 17308)
+++ gnucash/branches/gda-dev2/src/backend/sql/gnc-budget-sql.c	2008-07-12 03:12:24 UTC (rev 17309)
@@ -141,14 +141,16 @@
     GncBudget* pBudget = GNC_BUDGET(inst);
     const GUID* guid;
 	gint op;
+	gboolean is_infant;
 
 	g_return_if_fail( be != NULL );
 	g_return_if_fail( inst != NULL );
 	g_return_if_fail( GNC_IS_BUDGET(inst) );
 
+	is_infant = qof_instance_get_infant( inst );
 	if( qof_instance_get_destroying( inst ) ) {
 		op = OP_DB_DELETE;
-	} else if( be->is_pristine_db ) {
+	} else if( be->is_pristine_db || is_infant ) {
 		op = OP_DB_ADD;
 	} else {
 		op = OP_DB_ADD_OR_UPDATE;
@@ -159,7 +161,7 @@
     guid = qof_instance_get_guid( inst );
     if( !qof_instance_get_destroying(inst) ) {
 		gnc_sql_recurrence_save( be, guid, gnc_budget_get_recurrence( pBudget ) );
-        gnc_sql_slots_save( be, guid, qof_instance_get_slots( inst ) );
+        gnc_sql_slots_save( be, guid, is_infant, qof_instance_get_slots( inst ) );
     } else {
         gnc_sql_recurrence_delete( be, guid );
         gnc_sql_slots_delete( be, guid );

Modified: gnucash/branches/gda-dev2/src/backend/sql/gnc-commodity-sql.c
===================================================================
--- gnucash/branches/gda-dev2/src/backend/sql/gnc-commodity-sql.c	2008-07-12 01:12:57 UTC (rev 17308)
+++ gnucash/branches/gda-dev2/src/backend/sql/gnc-commodity-sql.c	2008-07-12 03:12:24 UTC (rev 17309)
@@ -186,14 +186,16 @@
 {
     const GUID* guid;
 	gint op;
+	gboolean is_infant;
 
 	g_return_if_fail( be != NULL );
 	g_return_if_fail( inst != NULL );
 	g_return_if_fail( GNC_IS_COMMODITY(inst) );
 
+	is_infant = qof_instance_get_infant( inst );
 	if( qof_instance_get_destroying( inst ) ) {
 		op = OP_DB_DELETE;
-	} else if( be->is_pristine_db ) {
+	} else if( be->is_pristine_db || is_infant ) {
 		op = OP_DB_ADD;
 	} else {
 		op = OP_DB_ADD_OR_UPDATE;
@@ -202,10 +204,9 @@
 
     // Delete old slot info
     guid = qof_instance_get_guid( inst );
-
     // Now, commit or delete any slots
     if( !qof_instance_get_destroying(inst) ) {
-        gnc_sql_slots_save( be, guid, qof_instance_get_slots( inst ) );
+        gnc_sql_slots_save( be, guid, is_infant, qof_instance_get_slots( inst ) );
     } else {
         gnc_sql_slots_delete( be, guid );
     }

Modified: gnucash/branches/gda-dev2/src/backend/sql/gnc-lots-sql.c
===================================================================
--- gnucash/branches/gda-dev2/src/backend/sql/gnc-lots-sql.c	2008-07-12 01:12:57 UTC (rev 17308)
+++ gnucash/branches/gda-dev2/src/backend/sql/gnc-lots-sql.c	2008-07-12 03:12:24 UTC (rev 17309)
@@ -167,14 +167,16 @@
 commit_lot( GncSqlBackend* be, QofInstance* inst )
 {
 	gint op;
+	gboolean is_infant;
 
 	g_return_if_fail( be != NULL );
 	g_return_if_fail( inst != NULL );
 	g_return_if_fail( GNC_IS_LOT(inst) );
 
+	is_infant = qof_instance_get_infant( inst );
 	if( qof_instance_get_destroying( inst ) ) {
 		op = OP_DB_DELETE;
-	} else if( be->is_pristine_db ) {
+	} else if( be->is_pristine_db || is_infant ) {
 		op = OP_DB_ADD;
 	} else {
 		op = OP_DB_ADD_OR_UPDATE;
@@ -184,6 +186,7 @@
     // Now, commit any slots
 	if( !qof_instance_get_destroying( inst ) ) {
     	gnc_sql_slots_save( be, qof_instance_get_guid( inst ),
+							is_infant,
                         	qof_instance_get_slots( inst ) );
 	} else {
     	gnc_sql_slots_delete( be, qof_instance_get_guid( inst ) );

Modified: gnucash/branches/gda-dev2/src/backend/sql/gnc-price-sql.c
===================================================================
--- gnucash/branches/gda-dev2/src/backend/sql/gnc-price-sql.c	2008-07-12 01:12:57 UTC (rev 17308)
+++ gnucash/branches/gda-dev2/src/backend/sql/gnc-price-sql.c	2008-07-12 03:12:24 UTC (rev 17309)
@@ -137,6 +137,7 @@
 {
     GNCPrice* pPrice = GNC_PRICE(inst);
 	gint op;
+	gboolean is_infant;
 
 	g_return_if_fail( be != NULL );
 	g_return_if_fail( inst != NULL );
@@ -146,9 +147,10 @@
 	gnc_sql_save_commodity( be, gnc_price_get_commodity( pPrice ) );
     gnc_sql_save_commodity( be, gnc_price_get_currency( pPrice ) );
 
+	is_infant = qof_instance_get_infant( inst );
 	if( qof_instance_get_destroying( inst ) ) {
 		op = OP_DB_DELETE;
-	} else if( be->is_pristine_db ) {
+	} else if( be->is_pristine_db || is_infant ) {
 		op = OP_DB_ADD;
 	} else {
 		op = OP_DB_ADD_OR_UPDATE;

Modified: gnucash/branches/gda-dev2/src/backend/sql/gnc-schedxaction-sql.c
===================================================================
--- gnucash/branches/gda-dev2/src/backend/sql/gnc-schedxaction-sql.c	2008-07-12 01:12:57 UTC (rev 17308)
+++ gnucash/branches/gda-dev2/src/backend/sql/gnc-schedxaction-sql.c	2008-07-12 03:12:24 UTC (rev 17309)
@@ -266,25 +266,27 @@
     SchedXaction* pSx = GNC_SX(inst);
     const GUID* guid;
 	gint op;
+	gboolean is_infant;
 
 	g_return_if_fail( inst != NULL );
 	g_return_if_fail( GNC_IS_SX(inst) );
 	g_return_if_fail( be != NULL );
 
+	is_infant = qof_instance_get_infant( inst );
 	if( qof_instance_get_destroying( inst ) ) {
 		op = OP_DB_DELETE;
-	} else if( be->is_pristine_db ) {
+	} else if( be->is_pristine_db || is_infant ) {
 		op = OP_DB_ADD;
 	} else {
 		op = OP_DB_ADD_OR_UPDATE;
 	}
-    (void)gnc_sql_do_db_operation( be, op, SCHEDXACTION_TABLE, /*GNC_ID_SCHEDXACTION*/GNC_SX_ID, pSx, col_table );
+    (void)gnc_sql_do_db_operation( be, op, SCHEDXACTION_TABLE, GNC_SX_ID, pSx, col_table );
     guid = qof_instance_get_guid( inst );
 	gnc_sql_recurrence_save_list( be, guid, gnc_sx_get_schedule( pSx ) );
 
     // Now, commit any slots
     if( !qof_instance_get_destroying(inst) ) {
-        gnc_sql_slots_save( be, guid, qof_instance_get_slots( inst ) );
+        gnc_sql_slots_save( be, guid, is_infant, qof_instance_get_slots( inst ) );
     } else {
         gnc_sql_slots_delete( be, guid );
     }

Modified: gnucash/branches/gda-dev2/src/backend/sql/gnc-slots-sql.c
===================================================================
--- gnucash/branches/gda-dev2/src/backend/sql/gnc-slots-sql.c	2008-07-12 01:12:57 UTC (rev 17308)
+++ gnucash/branches/gda-dev2/src/backend/sql/gnc-slots-sql.c	2008-07-12 03:12:24 UTC (rev 17309)
@@ -348,7 +348,7 @@
 }
 
 void
-gnc_sql_slots_save( GncSqlBackend* be, const GUID* guid, KvpFrame* pFrame )
+gnc_sql_slots_save( GncSqlBackend* be, const GUID* guid, gboolean is_infant, KvpFrame* pFrame )
 {
     slot_info_t slot_info;
 
@@ -357,7 +357,7 @@
 	g_return_if_fail( pFrame != NULL );
 
     // If this is not saving into a new db, clear out the old saved slots first
-	if( !be->is_pristine_db ) {
+	if( !be->is_pristine_db && !is_infant ) {
     	gnc_sql_slots_delete( be, guid );
 	}
 

Modified: gnucash/branches/gda-dev2/src/backend/sql/gnc-slots-sql.h
===================================================================
--- gnucash/branches/gda-dev2/src/backend/sql/gnc-slots-sql.h	2008-07-12 01:12:57 UTC (rev 17308)
+++ gnucash/branches/gda-dev2/src/backend/sql/gnc-slots-sql.h	2008-07-12 03:12:24 UTC (rev 17309)
@@ -32,9 +32,41 @@
 #include "qof.h"
 #include <gmodule.h>
 
-void gnc_sql_slots_save( GncSqlBackend* be, const GUID* guid, KvpFrame* pFrame );
+/**
+* gnc_sql_slots_save - Saves slots for an object to the db.
+*
+* @param be SQL backend
+* @param guid Object guid
+* @param is_infant Is this an infant object?
+* @param pFrame Top-level KVP frame
+*/
+void gnc_sql_slots_save( GncSqlBackend* be, const GUID* guid,
+					gboolean is_infant, KvpFrame* pFrame );
+
+/**
+* gnc_sql_slots_delete - Deletes slots for an object from the db.
+*
+* @param be SQL backend
+* @param guid Object guid
+*/
 void gnc_sql_slots_delete( GncSqlBackend* be, const GUID* guid );
+
+/**
+* gnc_sql_slots_load - Loads slots for an object from the db.
+*
+* @param be SQL backend
+* @param guid Object guid
+*/
 void gnc_sql_slots_load( GncSqlBackend* be, QofInstance* inst );
+
+/**
+* gnc_sql_slots_load_for_list - Loads slots for a list of objects from the db.
+* Loading slots for a list of objects can be faster than loading for one object
+* at a time because fewer SQL queries are used.
+*
+* @param be SQL backend
+* @param list List of objects
+*/
 void gnc_sql_slots_load_for_list( GncSqlBackend* be, GList* list );
 
 void gnc_sql_init_slots_handler( void );

Modified: gnucash/branches/gda-dev2/src/backend/sql/gnc-transaction-sql.c
===================================================================
--- gnucash/branches/gda-dev2/src/backend/sql/gnc-transaction-sql.c	2008-07-12 01:12:57 UTC (rev 17308)
+++ gnucash/branches/gda-dev2/src/backend/sql/gnc-transaction-sql.c	2008-07-12 03:12:24 UTC (rev 17309)
@@ -462,13 +462,15 @@
 commit_split( GncSqlBackend* be, QofInstance* inst )
 {
 	gint op;
+	gboolean is_infant;
 
 	g_return_if_fail( inst != NULL );
 	g_return_if_fail( be != NULL );
 
+	is_infant = qof_instance_get_infant( inst );
 	if( qof_instance_get_destroying( inst ) ) {
 		op = OP_DB_DELETE;
-	} else if( be->is_pristine_db ) {
+	} else if( be->is_pristine_db || is_infant ) {
 		op = OP_DB_ADD;
 	} else {
 		op = OP_DB_ADD_OR_UPDATE;
@@ -476,6 +478,7 @@
     (void)gnc_sql_do_db_operation( be, op, SPLIT_TABLE, GNC_ID_SPLIT, inst, split_col_table );
     gnc_sql_slots_save( be,
                         qof_instance_get_guid( inst ),
+						is_infant,
                         qof_instance_get_slots( inst ) );
 }
 
@@ -512,6 +515,7 @@
     Transaction* pTx = GNC_TRANS(inst);
     const GUID* guid;
 	gint op;
+	gboolean is_infant;
 
 	g_return_if_fail( inst != NULL );
 	g_return_if_fail( GNC_IS_TRANS(inst) );
@@ -520,9 +524,10 @@
     // Ensure the commodity is in the db
     gnc_sql_save_commodity( be, xaccTransGetCurrency( pTx ) );
 
+	is_infant = qof_instance_get_infant( inst );
 	if( qof_instance_get_destroying( inst ) ) {
 		op = OP_DB_DELETE;
-	} else if( be->is_pristine_db ) {
+	} else if( be->is_pristine_db || is_infant ) {
 		op = OP_DB_ADD;
 	} else {
 		op = OP_DB_ADD_OR_UPDATE;
@@ -538,22 +543,8 @@
 	}
 
     if( !qof_instance_get_destroying(inst) ) {
-        SplitList* splits;
-
         // Now, commit any slots and splits
-        gnc_sql_slots_save( be, guid, qof_instance_get_slots( inst ) );
-#if 0
-        splits = xaccTransGetSplitList( pTx );
-        save_splits( be, guid, splits );
-
-        /* Mark the splits as clean */
-        splits = xaccTransGetSplitList( pTx );
-        for( ; splits != NULL; splits = splits->next ) {
-            QofInstance* inst = QOF_INSTANCE(splits->data);
-
-            qof_instance_mark_clean(inst);
-        }
-#endif
+        gnc_sql_slots_save( be, guid, is_infant, qof_instance_get_slots( inst ) );
     } else {
         gnc_sql_slots_delete( be, guid );
     }

Modified: gnucash/branches/gda-dev2/src/business/business-core/sql/gnc-bill-term-sql.c
===================================================================
--- gnucash/branches/gda-dev2/src/business/business-core/sql/gnc-bill-term-sql.c	2008-07-12 01:12:57 UTC (rev 17308)
+++ gnucash/branches/gda-dev2/src/business/business-core/sql/gnc-bill-term-sql.c	2008-07-12 03:12:24 UTC (rev 17309)
@@ -162,21 +162,27 @@
 gnc_sql_save_billterm( GncSqlBackend* be, QofInstance* inst )
 {
     const GUID* guid;
+	gboolean is_infant;
+	gint op;
 
 	g_return_if_fail( inst != NULL );
 	g_return_if_fail( !GNC_IS_BILLTERM(inst) );
 	g_return_if_fail( be != NULL );
 
-    (void)gnc_sql_do_db_operation( be,
-                        (qof_instance_get_destroying(inst) ? OP_DB_DELETE : OP_DB_ADD_OR_UPDATE ),
-                        TABLE_NAME,
-                        GNC_ID_BILLTERM, inst,
-                        col_table );
+	is_infant = qof_instance_get_infant( inst );
+    if( qof_instance_get_destroying(inst) ) {
+		op = OP_DB_DELETE;
+	} else if( be->is_pristine_db || is_infant ) {
+		op = OP_DB_ADD;
+	} else {
+		op = OP_DB_ADD_OR_UPDATE;
+	}
+    (void)gnc_sql_do_db_operation( be, op, TABLE_NAME, GNC_ID_BILLTERM, inst, col_table );
 
     // Now, commit or delete any slots
     guid = qof_instance_get_guid( inst );
     if( !qof_instance_get_destroying(inst) ) {
-        gnc_sql_slots_save( be, guid, qof_instance_get_slots( inst ) );
+        gnc_sql_slots_save( be, guid, is_infant, qof_instance_get_slots( inst ) );
     } else {
         gnc_sql_slots_delete( be, guid );
     }

Modified: gnucash/branches/gda-dev2/src/business/business-core/sql/gnc-customer-sql.c
===================================================================
--- gnucash/branches/gda-dev2/src/business/business-core/sql/gnc-customer-sql.c	2008-07-12 01:12:57 UTC (rev 17308)
+++ gnucash/branches/gda-dev2/src/business/business-core/sql/gnc-customer-sql.c	2008-07-12 03:12:24 UTC (rev 17309)
@@ -143,21 +143,27 @@
 save_customer( GncSqlBackend* be, QofInstance* inst )
 {
     const GUID* guid;
+	gint op;
+	gboolean is_infant;
 
 	g_return_if_fail( inst != NULL );
 	g_return_if_fail( GNC_CUSTOMER(inst) );
 	g_return_if_fail( be != NULL );
 
-    (void)gnc_sql_do_db_operation( be,
-                        (qof_instance_get_destroying(inst) ? OP_DB_DELETE : OP_DB_ADD_OR_UPDATE ),
-                        TABLE_NAME,
-                        GNC_ID_CUSTOMER, inst,
-                        col_table );
+	is_infant = qof_instance_get_infant( inst );
+	if( qof_instance_get_destroying( inst ) ) {
+		op = OP_DB_DELETE;
+	} else if( be->is_pristine_db || is_infant ) {
+		op = OP_DB_ADD;
+	} else {
+		op = OP_DB_ADD_OR_UPDATE;
+	}
+    (void)gnc_sql_do_db_operation( be, op, TABLE_NAME, GNC_ID_CUSTOMER, inst, col_table );
 
     // Now, commit or delete any slots
     guid = qof_instance_get_guid( inst );
     if( !qof_instance_get_destroying(inst) ) {
-        gnc_sql_slots_save( be, guid, qof_instance_get_slots( inst ) );
+        gnc_sql_slots_save( be, guid, is_infant, qof_instance_get_slots( inst ) );
     } else {
         gnc_sql_slots_delete( be, guid );
     }

Modified: gnucash/branches/gda-dev2/src/business/business-core/sql/gnc-employee-sql.c
===================================================================
--- gnucash/branches/gda-dev2/src/business/business-core/sql/gnc-employee-sql.c	2008-07-12 01:12:57 UTC (rev 17308)
+++ gnucash/branches/gda-dev2/src/business/business-core/sql/gnc-employee-sql.c	2008-07-12 03:12:24 UTC (rev 17309)
@@ -138,26 +138,33 @@
 static void
 save_employee( GncSqlBackend* be, QofInstance* inst )
 {
-    GncEmployee* emp = GNC_EMPLOYEE(inst);
+    GncEmployee* emp;
     const GUID* guid;
+	gint op;
+	gboolean is_infant;
 
 	g_return_if_fail( inst != NULL );
 	g_return_if_fail( GNC_IS_EMPLOYEE(inst) );
 	g_return_if_fail( be != NULL );
 
     // Ensure the commodity is in the db
+    emp = GNC_EMPLOYEE(inst);
     gnc_sql_save_commodity( be, gncEmployeeGetCurrency( emp ) );
 
-    (void)gnc_sql_do_db_operation( be,
-                        (qof_instance_get_destroying(inst) ? OP_DB_DELETE : OP_DB_ADD_OR_UPDATE ),
-                        TABLE_NAME,
-                        GNC_ID_EMPLOYEE, emp,
-                        col_table );
+	is_infant = qof_instance_get_infant( inst );
+	if( qof_instance_get_destroying( inst ) ) {
+		op = OP_DB_DELETE;
+	} else if( be->is_pristine_db || is_infant ) {
+		op = OP_DB_ADD;
+	} else {
+		op = OP_DB_ADD_OR_UPDATE;
+	}
+    (void)gnc_sql_do_db_operation( be, op, TABLE_NAME, GNC_ID_EMPLOYEE, emp, col_table );
 
     // Now, commit or delete any slots
     guid = qof_instance_get_guid( inst );
     if( !qof_instance_get_destroying(inst) ) {
-        gnc_sql_slots_save( be, guid, qof_instance_get_slots( inst ) );
+        gnc_sql_slots_save( be, guid, is_infant, qof_instance_get_slots( inst ) );
     } else {
         gnc_sql_slots_delete( be, guid );
     }

Modified: gnucash/branches/gda-dev2/src/business/business-core/sql/gnc-entry-sql.c
===================================================================
--- gnucash/branches/gda-dev2/src/business/business-core/sql/gnc-entry-sql.c	2008-07-12 01:12:57 UTC (rev 17308)
+++ gnucash/branches/gda-dev2/src/business/business-core/sql/gnc-entry-sql.c	2008-07-12 03:12:24 UTC (rev 17309)
@@ -162,21 +162,27 @@
 save_entry( GncSqlBackend* be, QofInstance* inst )
 {
     const GUID* guid;
+	gint op;
+	gboolean is_infant;
 
 	g_return_if_fail( inst != NULL );
 	g_return_if_fail( GNC_IS_ENTRY(inst) );
 	g_return_if_fail( be != NULL );
 
-    (void)gnc_sql_do_db_operation( be,
-                        (qof_instance_get_destroying(inst) ? OP_DB_DELETE : OP_DB_ADD_OR_UPDATE ),
-                        TABLE_NAME,
-                        GNC_ID_ENTRY, inst,
-                        col_table );
+	is_infant = qof_instance_get_infant( inst );
+	if( qof_instance_get_destroying( inst ) ) {
+		op = OP_DB_DELETE;
+	} else if( be->is_pristine_db || is_infant ) {
+		op = OP_DB_ADD;
+	} else {
+		op = OP_DB_ADD_OR_UPDATE;
+	}
+    (void)gnc_sql_do_db_operation( be, op, TABLE_NAME, GNC_ID_ENTRY, inst, col_table );
 
     // Now, commit or delete any slots
     guid = qof_instance_get_guid( inst );
     if( !qof_instance_get_destroying(inst) ) {
-        gnc_sql_slots_save( be, guid, qof_instance_get_slots( inst ) );
+        gnc_sql_slots_save( be, guid, is_infant, qof_instance_get_slots( inst ) );
     } else {
         gnc_sql_slots_delete( be, guid );
     }

Modified: gnucash/branches/gda-dev2/src/business/business-core/sql/gnc-invoice-sql.c
===================================================================
--- gnucash/branches/gda-dev2/src/business/business-core/sql/gnc-invoice-sql.c	2008-07-12 01:12:57 UTC (rev 17308)
+++ gnucash/branches/gda-dev2/src/business/business-core/sql/gnc-invoice-sql.c	2008-07-12 03:12:24 UTC (rev 17309)
@@ -147,25 +147,32 @@
 save_invoice( GncSqlBackend* be, QofInstance* inst )
 {
     const GUID* guid;
-	GncInvoice* invoice = GNC_INVOICE(inst);
+	GncInvoice* invoice;
+	gint op;
+	gboolean is_infant;
 
 	g_return_if_fail( inst != NULL );
 	g_return_if_fail( GNC_IS_INVOICE(inst) );
 	g_return_if_fail( be != NULL );
 
     // Ensure the commodity is in the db
+	invoice = GNC_INVOICE(inst);
     gnc_sql_save_commodity( be, gncInvoiceGetCurrency( invoice ) );
 
-    (void)gnc_sql_do_db_operation( be,
-                        (qof_instance_get_destroying(inst) ? OP_DB_DELETE : OP_DB_ADD_OR_UPDATE ),
-                        TABLE_NAME,
-                        GNC_ID_INVOICE, inst,
-                        col_table );
+	is_infant = qof_instance_get_infant( inst );
+	if( qof_instance_get_destroying( inst ) ) {
+		op = OP_DB_DELETE;
+	} else if( be->is_pristine_db || is_infant ) {
+		op = OP_DB_ADD;
+	} else {
+		op = OP_DB_ADD_OR_UPDATE;
+	}
+    (void)gnc_sql_do_db_operation( be, op, TABLE_NAME, GNC_ID_INVOICE, inst, col_table );
 
     // Now, commit or delete any slots
     guid = qof_instance_get_guid( inst );
     if( !qof_instance_get_destroying(inst) ) {
-        gnc_sql_slots_save( be, guid, qof_instance_get_slots( inst ) );
+        gnc_sql_slots_save( be, guid, is_infant, qof_instance_get_slots( inst ) );
     } else {
         gnc_sql_slots_delete( be, guid );
     }

Modified: gnucash/branches/gda-dev2/src/business/business-core/sql/gnc-job-sql.c
===================================================================
--- gnucash/branches/gda-dev2/src/business/business-core/sql/gnc-job-sql.c	2008-07-12 01:12:57 UTC (rev 17308)
+++ gnucash/branches/gda-dev2/src/business/business-core/sql/gnc-job-sql.c	2008-07-12 03:12:24 UTC (rev 17309)
@@ -130,21 +130,27 @@
 save_job( GncSqlBackend* be, QofInstance* inst )
 {
     const GUID* guid;
+	gint op;
+	gboolean is_infant;
 
 	g_return_if_fail( inst != NULL );
 	g_return_if_fail( GNC_IS_JOB(inst) );
 	g_return_if_fail( be != NULL );
 
-    (void)gnc_sql_do_db_operation( be,
-                        (qof_instance_get_destroying(inst) ? OP_DB_DELETE : OP_DB_ADD_OR_UPDATE ),
-                        TABLE_NAME,
-                        GNC_ID_JOB, inst,
-                        col_table );
+	is_infant = qof_instance_get_infant( inst );
+	if( qof_instance_get_destroying( inst ) ) {
+		op = OP_DB_DELETE;
+	} else if( be->is_pristine_db || is_infant ) {
+		op = OP_DB_ADD;
+	} else {
+		op = OP_DB_ADD_OR_UPDATE;
+	}
+    (void)gnc_sql_do_db_operation( be, op, TABLE_NAME, GNC_ID_JOB, inst, col_table );
 
     // Now, commit or delete any slots
     guid = qof_instance_get_guid( inst );
     if( !qof_instance_get_destroying(inst) ) {
-        gnc_sql_slots_save( be, guid, qof_instance_get_slots( inst ) );
+        gnc_sql_slots_save( be, guid, is_infant, qof_instance_get_slots( inst ) );
     } else {
         gnc_sql_slots_delete( be, guid );
     }

Modified: gnucash/branches/gda-dev2/src/business/business-core/sql/gnc-order-sql.c
===================================================================
--- gnucash/branches/gda-dev2/src/business/business-core/sql/gnc-order-sql.c	2008-07-12 01:12:57 UTC (rev 17308)
+++ gnucash/branches/gda-dev2/src/business/business-core/sql/gnc-order-sql.c	2008-07-12 03:12:24 UTC (rev 17309)
@@ -131,21 +131,27 @@
 save_order( GncSqlBackend* be, QofInstance* inst )
 {
     const GUID* guid;
+	gint op;
+	gboolean is_infant;
 
 	g_return_if_fail( inst != NULL );
 	g_return_if_fail( GNC_IS_ORDER(inst) );
 	g_return_if_fail( be != NULL );
 
-    (void)gnc_sql_do_db_operation( be,
-                        (qof_instance_get_destroying(inst) ? OP_DB_DELETE : OP_DB_ADD_OR_UPDATE ),
-                        TABLE_NAME,
-                        GNC_ID_ORDER, inst,
-                        col_table );
+	is_infant = qof_instance_get_infant( inst );
+	if( qof_instance_get_destroying( inst ) ) {
+		op = OP_DB_DELETE;
+	} else if( be->is_pristine_db || is_infant ) {
+		op = OP_DB_ADD;
+	} else {
+		op = OP_DB_ADD_OR_UPDATE;
+	}
+    (void)gnc_sql_do_db_operation( be, op, TABLE_NAME, GNC_ID_ORDER, inst, col_table );
 
     // Now, commit or delete any slots
     guid = qof_instance_get_guid( inst );
     if( !qof_instance_get_destroying(inst) ) {
-        gnc_sql_slots_save( be, guid, qof_instance_get_slots( inst ) );
+        gnc_sql_slots_save( be, guid, is_infant, qof_instance_get_slots( inst ) );
     } else {
         gnc_sql_slots_delete( be, guid );
     }

Modified: gnucash/branches/gda-dev2/src/business/business-core/sql/gnc-tax-table-sql.c
===================================================================
--- gnucash/branches/gda-dev2/src/business/business-core/sql/gnc-tax-table-sql.c	2008-07-12 01:12:57 UTC (rev 17308)
+++ gnucash/branches/gda-dev2/src/business/business-core/sql/gnc-tax-table-sql.c	2008-07-12 03:12:24 UTC (rev 17309)
@@ -289,7 +289,7 @@
 	g_return_if_fail( be != NULL );
 	g_return_if_fail( guid != NULL );
 
-    /* First, delete the old slots for this object */
+    /* First, delete the old entries for this object */
     delete_all_tt_entries( be, guid );
 
 	for( entry = entries; entry != NULL; entry = entry->next ) {
@@ -305,23 +305,31 @@
 static void
 save_taxtable( GncSqlBackend* be, QofInstance* inst )
 {
-    GncTaxTable* tt = GNC_TAXTABLE(inst);
+    GncTaxTable* tt;
     const GUID* guid;
+	gint op;
+	gboolean is_infant;
 
 	g_return_if_fail( inst != NULL );
 	g_return_if_fail( GNC_IS_TAXTABLE(inst) );
 	g_return_if_fail( be != NULL );
 
-    (void)gnc_sql_do_db_operation( be,
-                        (qof_instance_get_destroying(inst) ? OP_DB_DELETE : OP_DB_ADD_OR_UPDATE ),
-                        TT_TABLE_NAME,
-                        GNC_ID_TAXTABLE, tt,
-                        tt_col_table );
+    tt = GNC_TAXTABLE(inst);
 
+	is_infant = qof_instance_get_infant( inst );
+	if( qof_instance_get_destroying( inst ) ) {
+		op = OP_DB_DELETE;
+	} else if( be->is_pristine_db || is_infant ) {
+		op = OP_DB_ADD;
+	} else {
+		op = OP_DB_ADD_OR_UPDATE;
+	}
+    (void)gnc_sql_do_db_operation( be, op, TT_TABLE_NAME, GNC_ID_TAXTABLE, tt, tt_col_table );
+
     // Now, commit or delete any slots and tax table entries
     guid = qof_instance_get_guid( inst );
     if( !qof_instance_get_destroying(inst) ) {
-        gnc_sql_slots_save( be, guid, qof_instance_get_slots( inst ) );
+        gnc_sql_slots_save( be, guid, is_infant, qof_instance_get_slots( inst ) );
 		save_tt_entries( be, guid, gncTaxTableGetEntries( tt ) );
     } else {
         gnc_sql_slots_delete( be, guid );

Modified: gnucash/branches/gda-dev2/src/business/business-core/sql/gnc-vendor-sql.c
===================================================================
--- gnucash/branches/gda-dev2/src/business/business-core/sql/gnc-vendor-sql.c	2008-07-12 01:12:57 UTC (rev 17308)
+++ gnucash/branches/gda-dev2/src/business/business-core/sql/gnc-vendor-sql.c	2008-07-12 03:12:24 UTC (rev 17309)
@@ -143,26 +143,33 @@
 static void
 save_vendor( GncSqlBackend* be, QofInstance* inst )
 {
-    GncVendor* v = GNC_VENDOR(inst);
+    GncVendor* v;
     const GUID* guid;
+	gint op;
+	gboolean is_infant;
 
 	g_return_if_fail( inst != NULL );
 	g_return_if_fail( GNC_IS_VENDOR(inst) );
 	g_return_if_fail( be != NULL );
 
     // Ensure the commodity is in the db
+    v = GNC_VENDOR(inst);
     gnc_sql_save_commodity( be, gncVendorGetCurrency( v ) );
 
-    (void)gnc_sql_do_db_operation( be,
-                        (qof_instance_get_destroying(inst) ? OP_DB_DELETE : OP_DB_ADD_OR_UPDATE ),
-                        TABLE_NAME,
-                        GNC_ID_VENDOR, v,
-                        col_table );
+	is_infant = qof_instance_get_infant( inst );
+	if( qof_instance_get_destroying( inst ) ) {
+		op = OP_DB_DELETE;
+	} else if( be->is_pristine_db || is_infant ) {
+		op = OP_DB_ADD;
+	} else {
+		op = OP_DB_ADD_OR_UPDATE;
+	}
+    (void)gnc_sql_do_db_operation( be, op, TABLE_NAME, GNC_ID_VENDOR, v, col_table );
 
     // Now, commit or delete any slots
     guid = qof_instance_get_guid( inst );
     if( !qof_instance_get_destroying(inst) ) {
-        gnc_sql_slots_save( be, guid, qof_instance_get_slots( inst ) );
+        gnc_sql_slots_save( be, guid, is_infant, qof_instance_get_slots( inst ) );
     } else {
         gnc_sql_slots_delete( be, guid );
     }



More information about the gnucash-changes mailing list