2008-08-01 16:02:07 +00:00
|
|
|
/********************************************************************
|
|
|
|
|
* gnc-commodity-sql.c: load and save data to SQL *
|
|
|
|
|
* *
|
|
|
|
|
* This program is free software; you can redistribute it and/or *
|
|
|
|
|
* modify it under the terms of the GNU General Public License as *
|
|
|
|
|
* published by the Free Software Foundation; either version 2 of *
|
|
|
|
|
* the License, or (at your option) any later version. *
|
|
|
|
|
* *
|
|
|
|
|
* This program is distributed in the hope that it will be useful, *
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
|
|
* GNU General Public License for more details. *
|
|
|
|
|
* *
|
|
|
|
|
* You should have received a copy of the GNU General Public License*
|
|
|
|
|
* along with this program; if not, contact: *
|
|
|
|
|
* *
|
|
|
|
|
* Free Software Foundation Voice: +1-617-542-5942 *
|
|
|
|
|
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
|
|
|
|
|
* Boston, MA 02110-1301, USA gnu@gnu.org *
|
|
|
|
|
\********************************************************************/
|
|
|
|
|
/** @file gnc-commodity-sql.c
|
2010-03-27 21:02:18 +00:00
|
|
|
* @brief load and save data to SQL
|
2008-08-01 16:02:07 +00:00
|
|
|
* @author Copyright (c) 2006-2008 Phil Longstaff <plongstaff@rogers.com>
|
|
|
|
|
*
|
|
|
|
|
* This file implements the top-level QofBackend API for saving/
|
|
|
|
|
* restoring data to/from an SQL db
|
|
|
|
|
*/
|
2016-06-07 10:39:46 -04:00
|
|
|
#include <guid.hpp>
|
2015-11-28 13:40:55 -08:00
|
|
|
extern "C"
|
|
|
|
|
{
|
2008-08-01 16:02:07 +00:00
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
|
|
#include <glib.h>
|
|
|
|
|
|
|
|
|
|
#include "qof.h"
|
|
|
|
|
#include "gnc-commodity.h"
|
2015-11-28 13:40:55 -08:00
|
|
|
}
|
2008-08-01 16:02:07 +00:00
|
|
|
|
2015-11-28 13:40:55 -08:00
|
|
|
#include "gnc-backend-sql.h"
|
2008-08-01 16:02:07 +00:00
|
|
|
#include "gnc-commodity-sql.h"
|
|
|
|
|
#include "gnc-slots-sql.h"
|
|
|
|
|
|
2009-03-09 17:17:57 +00:00
|
|
|
#if defined( S_SPLINT_S )
|
|
|
|
|
#include "splint-defs.h"
|
|
|
|
|
#endif
|
2008-08-01 16:02:07 +00:00
|
|
|
|
2016-03-12 14:04:40 -08:00
|
|
|
static QofLogModule log_module = G_LOG_DOMAIN;
|
2009-03-09 17:17:57 +00:00
|
|
|
|
2016-03-12 14:04:40 -08:00
|
|
|
static gpointer get_quote_source_name (gpointer pObject);
|
|
|
|
|
static void set_quote_source_name (gpointer pObject, gpointer pValue);
|
2008-08-01 16:02:07 +00:00
|
|
|
|
|
|
|
|
#define COMMODITIES_TABLE "commodities"
|
|
|
|
|
#define TABLE_VERSION 1
|
|
|
|
|
|
|
|
|
|
#define COMMODITY_MAX_NAMESPACE_LEN 2048
|
|
|
|
|
#define COMMODITY_MAX_MNEMONIC_LEN 2048
|
|
|
|
|
#define COMMODITY_MAX_FULLNAME_LEN 2048
|
|
|
|
|
#define COMMODITY_MAX_CUSIP_LEN 2048
|
|
|
|
|
#define COMMODITY_MAX_QUOTESOURCE_LEN 2048
|
|
|
|
|
#define COMMODITY_MAX_QUOTE_TZ_LEN 2048
|
|
|
|
|
|
2016-03-12 11:13:05 -08:00
|
|
|
static const EntryVec col_table
|
2010-03-27 21:02:18 +00:00
|
|
|
{
|
|
|
|
|
{ "guid", CT_GUID, 0, COL_NNUL | COL_PKEY, "guid" },
|
|
|
|
|
{
|
|
|
|
|
"namespace", CT_STRING, COMMODITY_MAX_NAMESPACE_LEN, COL_NNUL, NULL, NULL,
|
|
|
|
|
(QofAccessFunc)gnc_commodity_get_namespace,
|
|
|
|
|
(QofSetterFunc)gnc_commodity_set_namespace
|
|
|
|
|
},
|
2008-08-01 16:02:07 +00:00
|
|
|
{ "mnemonic", CT_STRING, COMMODITY_MAX_MNEMONIC_LEN, COL_NNUL, "mnemonic" },
|
|
|
|
|
{ "fullname", CT_STRING, COMMODITY_MAX_FULLNAME_LEN, 0, "fullname" },
|
|
|
|
|
{ "cusip", CT_STRING, COMMODITY_MAX_CUSIP_LEN, 0, "cusip" },
|
|
|
|
|
{ "fraction", CT_INT, 0, COL_NNUL, "fraction" },
|
|
|
|
|
{ "quote_flag", CT_BOOLEAN, 0, COL_NNUL, "quote_flag" },
|
2010-03-27 21:02:18 +00:00
|
|
|
{
|
|
|
|
|
"quote_source", CT_STRING, COMMODITY_MAX_QUOTESOURCE_LEN, 0, NULL, NULL,
|
|
|
|
|
(QofAccessFunc)get_quote_source_name, set_quote_source_name
|
|
|
|
|
},
|
2008-08-01 16:02:07 +00:00
|
|
|
{ "quote_tz", CT_STRING, COMMODITY_MAX_QUOTE_TZ_LEN, 0, "quote-tz" },
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* ================================================================= */
|
|
|
|
|
|
2016-03-12 13:34:22 -08:00
|
|
|
static gpointer
|
2016-03-12 14:04:40 -08:00
|
|
|
get_quote_source_name (gpointer pObject)
|
2008-08-01 16:02:07 +00:00
|
|
|
{
|
2009-03-09 17:17:57 +00:00
|
|
|
const gnc_commodity* pCommodity;
|
2008-08-01 16:02:07 +00:00
|
|
|
|
2016-03-12 14:04:40 -08:00
|
|
|
g_return_val_if_fail (pObject != NULL, NULL);
|
|
|
|
|
g_return_val_if_fail (GNC_IS_COMMODITY (pObject), NULL);
|
2008-08-01 16:02:07 +00:00
|
|
|
|
2016-03-12 14:04:40 -08:00
|
|
|
pCommodity = GNC_COMMODITY (pObject);
|
|
|
|
|
return (gpointer)gnc_quote_source_get_internal_name (
|
|
|
|
|
gnc_commodity_get_quote_source (pCommodity));
|
2008-08-01 16:02:07 +00:00
|
|
|
}
|
|
|
|
|
|
2010-03-27 21:02:18 +00:00
|
|
|
static void
|
2016-03-12 14:04:40 -08:00
|
|
|
set_quote_source_name (gpointer pObject, gpointer pValue)
|
2008-08-01 16:02:07 +00:00
|
|
|
{
|
2009-03-09 17:17:57 +00:00
|
|
|
gnc_commodity* pCommodity;
|
2008-08-01 16:02:07 +00:00
|
|
|
const gchar* quote_source_name = (const gchar*)pValue;
|
|
|
|
|
gnc_quote_source* quote_source;
|
|
|
|
|
|
2016-03-12 14:04:40 -08:00
|
|
|
g_return_if_fail (pObject != NULL);
|
|
|
|
|
g_return_if_fail (GNC_IS_COMMODITY (pObject));
|
2008-08-01 16:02:07 +00:00
|
|
|
|
2016-03-12 14:04:40 -08:00
|
|
|
if (pValue == NULL) return;
|
2008-08-01 16:02:07 +00:00
|
|
|
|
2016-03-12 14:04:40 -08:00
|
|
|
pCommodity = GNC_COMMODITY (pObject);
|
|
|
|
|
quote_source = gnc_quote_source_lookup_by_internal (quote_source_name);
|
|
|
|
|
gnc_commodity_set_quote_source (pCommodity, quote_source);
|
2008-08-01 16:02:07 +00:00
|
|
|
}
|
|
|
|
|
|
2016-03-12 13:34:22 -08:00
|
|
|
static gnc_commodity*
|
2016-03-12 14:04:40 -08:00
|
|
|
load_single_commodity (GncSqlBackend* be, GncSqlRow* row)
|
2008-08-01 16:02:07 +00:00
|
|
|
{
|
2011-11-13 21:33:29 +00:00
|
|
|
QofBook* pBook = be->book;
|
2008-08-01 16:02:07 +00:00
|
|
|
gnc_commodity* pCommodity;
|
|
|
|
|
|
2016-03-12 14:04:40 -08:00
|
|
|
pCommodity = gnc_commodity_new (pBook, NULL, NULL, NULL, NULL, 100);
|
|
|
|
|
gnc_commodity_begin_edit (pCommodity);
|
|
|
|
|
gnc_sql_load_object (be, row, GNC_ID_COMMODITY, pCommodity, col_table);
|
|
|
|
|
gnc_commodity_commit_edit (pCommodity);
|
2008-08-01 16:02:07 +00:00
|
|
|
|
|
|
|
|
return pCommodity;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2016-03-12 14:04:40 -08:00
|
|
|
load_all_commodities (GncSqlBackend* be)
|
2008-08-01 16:02:07 +00:00
|
|
|
{
|
|
|
|
|
GncSqlStatement* stmt;
|
|
|
|
|
GncSqlResult* result;
|
|
|
|
|
gnc_commodity_table* pTable;
|
|
|
|
|
|
2016-03-12 14:04:40 -08:00
|
|
|
pTable = gnc_commodity_table_get_table (be->book);
|
|
|
|
|
stmt = gnc_sql_create_select_statement (be, COMMODITIES_TABLE);
|
|
|
|
|
if (stmt == NULL) return;
|
|
|
|
|
result = gnc_sql_execute_select_statement (be, stmt);
|
|
|
|
|
gnc_sql_statement_dispose (stmt);
|
|
|
|
|
if (result != NULL)
|
2010-03-27 21:02:18 +00:00
|
|
|
{
|
2008-08-01 16:02:07 +00:00
|
|
|
gnc_commodity* pCommodity;
|
2016-03-12 14:04:40 -08:00
|
|
|
GncSqlRow* row = gnc_sql_result_get_first_row (result);
|
2010-03-27 21:02:18 +00:00
|
|
|
gchar* sql;
|
2008-08-01 16:02:07 +00:00
|
|
|
|
2016-03-12 14:04:40 -08:00
|
|
|
while (row != NULL)
|
2010-03-27 21:02:18 +00:00
|
|
|
{
|
2016-03-12 14:04:40 -08:00
|
|
|
pCommodity = load_single_commodity (be, row);
|
2008-08-01 16:02:07 +00:00
|
|
|
|
2016-03-12 14:04:40 -08:00
|
|
|
if (pCommodity != NULL)
|
2010-03-27 21:02:18 +00:00
|
|
|
{
|
2010-03-27 21:01:21 +00:00
|
|
|
GncGUID guid;
|
2008-08-01 16:02:07 +00:00
|
|
|
|
2016-03-12 14:04:40 -08:00
|
|
|
guid = *qof_instance_get_guid (QOF_INSTANCE (pCommodity));
|
|
|
|
|
pCommodity = gnc_commodity_table_insert (pTable, pCommodity);
|
|
|
|
|
if (qof_instance_is_dirty (QOF_INSTANCE (pCommodity)))
|
|
|
|
|
gnc_sql_push_commodity_for_postload_processing (be, (gpointer)pCommodity);
|
|
|
|
|
qof_instance_set_guid (QOF_INSTANCE (pCommodity), &guid);
|
2008-08-01 16:02:07 +00:00
|
|
|
}
|
2016-03-12 14:04:40 -08:00
|
|
|
row = gnc_sql_result_get_next_row (result);
|
2008-08-01 16:02:07 +00:00
|
|
|
}
|
2016-03-12 14:04:40 -08:00
|
|
|
gnc_sql_result_dispose (result);
|
2008-08-01 16:02:07 +00:00
|
|
|
|
2016-03-12 14:04:40 -08:00
|
|
|
sql = g_strdup_printf ("SELECT DISTINCT guid FROM %s", COMMODITIES_TABLE);
|
|
|
|
|
gnc_sql_slots_load_for_sql_subquery (be, sql,
|
|
|
|
|
(BookLookupFn)gnc_commodity_find_commodity_by_guid);
|
|
|
|
|
g_free (sql);
|
2008-08-01 16:02:07 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/* ================================================================= */
|
|
|
|
|
static void
|
2016-03-12 14:04:40 -08:00
|
|
|
create_commodities_tables (GncSqlBackend* be)
|
2008-08-01 16:02:07 +00:00
|
|
|
{
|
2010-03-27 21:02:18 +00:00
|
|
|
gint version;
|
2008-08-01 16:02:07 +00:00
|
|
|
|
2016-03-12 14:04:40 -08:00
|
|
|
g_return_if_fail (be != NULL);
|
2008-08-01 16:02:07 +00:00
|
|
|
|
2016-03-12 14:04:40 -08:00
|
|
|
version = gnc_sql_get_table_version (be, COMMODITIES_TABLE);
|
|
|
|
|
if (version == 0)
|
2010-03-27 21:02:18 +00:00
|
|
|
{
|
2016-03-12 14:04:40 -08:00
|
|
|
(void)gnc_sql_create_table (be, COMMODITIES_TABLE, TABLE_VERSION, col_table);
|
2008-08-01 16:02:07 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ================================================================= */
|
2009-08-08 16:19:57 +00:00
|
|
|
static gboolean
|
2016-03-12 14:04:40 -08:00
|
|
|
do_commit_commodity (GncSqlBackend* be, QofInstance* inst,
|
|
|
|
|
gboolean force_insert)
|
2009-08-08 16:19:57 +00:00
|
|
|
{
|
2010-03-27 21:02:18 +00:00
|
|
|
const GncGUID* guid;
|
|
|
|
|
gboolean is_infant;
|
2015-11-28 13:40:55 -08:00
|
|
|
E_DB_OPERATION op;
|
2010-03-27 21:02:18 +00:00
|
|
|
gboolean is_ok;
|
|
|
|
|
|
2016-03-12 14:04:40 -08:00
|
|
|
is_infant = qof_instance_get_infant (inst);
|
|
|
|
|
if (qof_instance_get_destroying (inst))
|
2010-03-27 21:02:18 +00:00
|
|
|
{
|
|
|
|
|
op = OP_DB_DELETE;
|
|
|
|
|
}
|
2016-03-12 14:04:40 -08:00
|
|
|
else if (be->is_pristine_db || is_infant || force_insert)
|
2010-03-27 21:02:18 +00:00
|
|
|
{
|
|
|
|
|
op = OP_DB_INSERT;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
op = OP_DB_UPDATE;
|
|
|
|
|
}
|
2016-03-12 14:04:40 -08:00
|
|
|
is_ok = gnc_sql_do_db_operation (be, op, COMMODITIES_TABLE, GNC_ID_COMMODITY,
|
|
|
|
|
inst, col_table);
|
2009-08-08 16:19:57 +00:00
|
|
|
|
2016-03-12 14:04:40 -08:00
|
|
|
if (is_ok)
|
2010-03-27 21:02:18 +00:00
|
|
|
{
|
|
|
|
|
// Now, commit any slots
|
2016-03-12 14:04:40 -08:00
|
|
|
guid = qof_instance_get_guid (inst);
|
|
|
|
|
if (!qof_instance_get_destroying (inst))
|
2010-03-27 21:02:18 +00:00
|
|
|
{
|
2016-03-12 14:04:40 -08:00
|
|
|
is_ok = gnc_sql_slots_save (be, guid, is_infant, inst);
|
2010-03-27 21:02:18 +00:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2016-03-12 14:04:40 -08:00
|
|
|
is_ok = gnc_sql_slots_delete (be, guid);
|
2010-03-27 21:02:18 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return is_ok;
|
2009-08-08 16:19:57 +00:00
|
|
|
}
|
|
|
|
|
|
2008-09-27 17:31:23 +00:00
|
|
|
static gboolean
|
2016-03-12 14:04:40 -08:00
|
|
|
commit_commodity (GncSqlBackend* be, QofInstance* inst)
|
2008-08-01 16:02:07 +00:00
|
|
|
{
|
2016-03-12 14:04:40 -08:00
|
|
|
g_return_val_if_fail (be != NULL, FALSE);
|
|
|
|
|
g_return_val_if_fail (inst != NULL, FALSE);
|
|
|
|
|
g_return_val_if_fail (GNC_IS_COMMODITY (inst), FALSE);
|
2008-08-01 16:02:07 +00:00
|
|
|
|
2016-03-12 14:04:40 -08:00
|
|
|
return do_commit_commodity (be, inst, FALSE);
|
2008-08-01 16:02:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
2016-03-12 14:04:40 -08:00
|
|
|
is_commodity_in_db (GncSqlBackend* be, gnc_commodity* pCommodity)
|
2008-08-01 16:02:07 +00:00
|
|
|
{
|
2016-03-12 14:04:40 -08:00
|
|
|
g_return_val_if_fail (be != NULL, FALSE);
|
|
|
|
|
g_return_val_if_fail (pCommodity != NULL, FALSE);
|
2008-08-01 16:02:07 +00:00
|
|
|
|
2016-03-12 14:04:40 -08:00
|
|
|
return gnc_sql_object_is_it_in_db (be, COMMODITIES_TABLE, GNC_ID_COMMODITY,
|
|
|
|
|
pCommodity, col_table);
|
2008-08-01 16:02:07 +00:00
|
|
|
}
|
|
|
|
|
|
2008-09-27 17:31:23 +00:00
|
|
|
gboolean
|
2016-03-12 14:04:40 -08:00
|
|
|
gnc_sql_save_commodity (GncSqlBackend* be, gnc_commodity* pCommodity)
|
2008-08-01 16:02:07 +00:00
|
|
|
{
|
2010-03-27 21:02:18 +00:00
|
|
|
gboolean is_ok = TRUE;
|
2008-09-27 17:31:23 +00:00
|
|
|
|
2016-03-12 14:04:40 -08:00
|
|
|
g_return_val_if_fail (be != NULL, FALSE);
|
|
|
|
|
g_return_val_if_fail (pCommodity != NULL, FALSE);
|
2008-08-01 16:02:07 +00:00
|
|
|
|
2016-03-12 14:04:40 -08:00
|
|
|
if (!is_commodity_in_db (be, pCommodity))
|
2010-03-27 21:02:18 +00:00
|
|
|
{
|
2016-03-12 14:04:40 -08:00
|
|
|
is_ok = do_commit_commodity (be, QOF_INSTANCE (pCommodity), TRUE);
|
2008-08-01 16:02:07 +00:00
|
|
|
}
|
2008-09-27 17:31:23 +00:00
|
|
|
|
2010-03-27 21:02:18 +00:00
|
|
|
return is_ok;
|
2008-08-01 16:02:07 +00:00
|
|
|
}
|
|
|
|
|
|
2014-09-04 16:26:32 -07:00
|
|
|
void
|
2016-03-12 14:04:40 -08:00
|
|
|
gnc_sql_commit_commodity (gnc_commodity* pCommodity)
|
2014-09-04 16:26:32 -07:00
|
|
|
{
|
|
|
|
|
g_return_if_fail (pCommodity != NULL);
|
|
|
|
|
g_return_if_fail (GNC_IS_COMMODITY (pCommodity));
|
|
|
|
|
gnc_commodity_begin_edit (pCommodity);
|
|
|
|
|
gnc_commodity_commit_edit (pCommodity);
|
|
|
|
|
}
|
|
|
|
|
|
2008-08-01 16:02:07 +00:00
|
|
|
/* ----------------------------------------------------------------- */
|
|
|
|
|
|
|
|
|
|
static void
|
2016-03-12 14:04:40 -08:00
|
|
|
load_commodity_guid (const GncSqlBackend* be, GncSqlRow* row,
|
|
|
|
|
QofSetterFunc setter, gpointer pObject,
|
2016-03-12 11:13:05 -08:00
|
|
|
const GncSqlColumnTableEntry& table_row)
|
2008-08-01 16:02:07 +00:00
|
|
|
{
|
2010-03-27 21:01:21 +00:00
|
|
|
GncGUID guid;
|
2010-03-27 21:02:18 +00:00
|
|
|
gnc_commodity* commodity = NULL;
|
|
|
|
|
|
2016-03-12 14:04:40 -08:00
|
|
|
g_return_if_fail (be != NULL);
|
|
|
|
|
g_return_if_fail (row != NULL);
|
|
|
|
|
g_return_if_fail (pObject != NULL);
|
2010-03-27 21:02:18 +00:00
|
|
|
|
2016-03-27 23:48:02 -07:00
|
|
|
try
|
2010-03-27 21:02:18 +00:00
|
|
|
{
|
2016-03-27 23:48:02 -07:00
|
|
|
auto val = row->get_string_at_col (table_row.col_name);
|
|
|
|
|
(void)string_to_guid (val.c_str(), &guid);
|
2016-03-12 14:04:40 -08:00
|
|
|
commodity = gnc_commodity_find_commodity_by_guid (&guid, be->book);
|
|
|
|
|
if (commodity != NULL)
|
2010-03-27 21:02:18 +00:00
|
|
|
{
|
2016-03-12 11:13:05 -08:00
|
|
|
if (table_row.gobj_param_name != NULL)
|
2010-03-27 21:02:18 +00:00
|
|
|
{
|
2016-03-12 14:04:40 -08:00
|
|
|
qof_instance_increase_editlevel (pObject);
|
2016-03-12 11:13:05 -08:00
|
|
|
g_object_set (pObject, table_row.gobj_param_name, commodity, NULL);
|
2016-03-12 14:04:40 -08:00
|
|
|
qof_instance_decrease_editlevel (pObject);
|
2010-03-27 21:02:18 +00:00
|
|
|
}
|
2016-03-12 14:04:40 -08:00
|
|
|
else if (setter != NULL)
|
2010-03-27 21:02:18 +00:00
|
|
|
{
|
2016-03-12 14:04:40 -08:00
|
|
|
(*setter) (pObject, (const gpointer)commodity);
|
2010-03-27 21:02:18 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2016-03-27 23:48:02 -07:00
|
|
|
PWARN ("Commodity ref '%s' not found", val.c_str());
|
2010-03-27 21:02:18 +00:00
|
|
|
}
|
|
|
|
|
}
|
2016-03-27 23:48:02 -07:00
|
|
|
catch (std::invalid_argument) {}
|
2008-08-01 16:02:07 +00:00
|
|
|
}
|
|
|
|
|
|
2008-08-02 18:57:13 +00:00
|
|
|
static GncSqlColumnTypeHandler commodity_guid_handler
|
2010-03-27 21:02:18 +00:00
|
|
|
= { load_commodity_guid,
|
|
|
|
|
gnc_sql_add_objectref_guid_col_info_to_list,
|
2016-03-12 11:32:27 -08:00
|
|
|
gnc_sql_add_objectref_guid_to_vec
|
2010-03-27 21:02:18 +00:00
|
|
|
};
|
2008-08-01 16:02:07 +00:00
|
|
|
/* ================================================================= */
|
|
|
|
|
void
|
2016-03-12 14:04:40 -08:00
|
|
|
gnc_sql_init_commodity_handler (void)
|
2008-08-01 16:02:07 +00:00
|
|
|
{
|
|
|
|
|
static GncSqlObjectBackend be_data =
|
|
|
|
|
{
|
|
|
|
|
GNC_SQL_BACKEND_VERSION,
|
|
|
|
|
GNC_ID_COMMODITY,
|
|
|
|
|
commit_commodity, /* commit */
|
|
|
|
|
load_all_commodities, /* initial_load */
|
2009-02-16 21:30:21 +00:00
|
|
|
create_commodities_tables, /* create_tables */
|
2010-03-27 21:02:18 +00:00
|
|
|
NULL, /* compile_query */
|
|
|
|
|
NULL, /* run_query */
|
|
|
|
|
NULL, /* free_query */
|
|
|
|
|
NULL /* write */
|
2008-08-01 16:02:07 +00:00
|
|
|
};
|
|
|
|
|
|
2016-08-04 14:41:40 -07:00
|
|
|
gnc_sql_register_backend(&be_data);
|
2016-03-12 14:04:40 -08:00
|
|
|
gnc_sql_register_col_type_handler (CT_COMMODITYREF, &commodity_guid_handler);
|
2008-08-01 16:02:07 +00:00
|
|
|
}
|
|
|
|
|
/* ========================== END OF FILE ===================== */
|