From: scottmk <scottmk@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Date: Sat, 3 Apr 2010 05:48:39 +0000 (+0000)
Subject: Create a separate function for adding datatype information
X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=867d78c146fc0be1bed6e8ca30014694274fdf2e;p=evergreen%2Fpines.git

Create a separate function for adding datatype information
from the database to the IDL information.  That way we can
call it in other contexts, e.g. the forthcoming
query set server.

M    Open-ILS/src/c-apps/oils_cstore.c


git-svn-id: svn://svn.open-ils.org/ILS/trunk@16115 dcc99617-32d9-48b4-a31d-7c20da2025e4
---

diff --git a/Open-ILS/src/c-apps/oils_cstore.c b/Open-ILS/src/c-apps/oils_cstore.c
index d44d208e69..665cbc2b67 100644
--- a/Open-ILS/src/c-apps/oils_cstore.c
+++ b/Open-ILS/src/c-apps/oils_cstore.c
@@ -157,9 +157,6 @@ static int verifyObjectPCRUD( osrfMethodContext*, const jsonObject* );
 static char* org_tree_root( osrfMethodContext* ctx );
 static jsonObject* single_hash( const char* key, const char* value );
 
-static const int enforce_pcrud = ENFORCE_PCRUD;     // Boolean
-static const char modulename[] = MODULENAME;
-
 static int child_initialized = 0;   /* boolean */
 
 static dbi_conn writehandle; /* our MASTER db connection */
@@ -172,6 +169,18 @@ static int max_flesh_depth = 100;
 // confusing because the top level of the query is at the bottom of the stack.
 static QueryFrame* curr_query = NULL;
 
+//----------------------------------
+
+int oilsExtendIDL( void );
+
+static dbi_conn writehandle; /* our MASTER db connection */
+static dbi_conn dbhandle; /* our CURRENT db connection */
+//static osrfHash * readHandles;
+
+static const int enforce_pcrud = ENFORCE_PCRUD;     // Boolean
+static const char modulename[] = MODULENAME;
+
+
 /**
 	@brief Disconnect from the database.
 
@@ -540,6 +549,26 @@ int osrfAppChildInit() {
 
 	osrfLogInfo(OSRF_LOG_MARK, "%s successfully connected to the database", modulename );
 
+	// Add datatypes from database to the fields in the IDL
+	if( oilsExtendIDL() ) {
+		osrfLogError( OSRF_LOG_MARK, "Error extending the IDL" );
+		return -1;
+	}
+	else
+		return 0;
+}
+
+/**
+	@brief Add datatypes from the database to the fields in the IDL.
+	@return Zero if successful, or 1 upon error.
+
+	For each relevant class in the IDL: ask the database for the datatype of every field.
+	In particular, determine which fields are text fields and which fields are numeric
+	fields, so that we know whether to enclose their values in quotes.
+
+	At this writing this function does not detect any errors, so it always returns zero.
+*/
+int oilsExtendIDL( void ) {
 	osrfHashIterator* class_itr = osrfNewHashIterator( oilsIDL() );
 	osrfHash* class = NULL;
 	growing_buffer* query_buf = buffer_init( 64 );