[open-ils-commits] r16821 - in trunk/Open-ILS: include/openils src/c-apps (scottmk)

svn at svn.open-ils.org svn at svn.open-ils.org
Mon Jun 28 11:43:31 EDT 2010


Author: scottmk
Date: 2010-06-28 11:43:28 -0400 (Mon, 28 Jun 2010)
New Revision: 16821

Modified:
   trunk/Open-ILS/include/openils/oils_buildq.h
   trunk/Open-ILS/src/c-apps/buildSQL.c
   trunk/Open-ILS/src/c-apps/oils_storedq.c
Log:
Support function calls with subfields, e.g. (func(args))."id".

Note that this support treats the subfield as an optional
component of the functional call, not as a type of expression
in its own right.  A subsequent commit will eliminate the "xfld"
expression type.

M    Open-ILS/include/openils/oils_buildq.h
M    Open-ILS/src/c-apps/oils_storedq.c
M    Open-ILS/src/c-apps/buildSQL.c


Modified: trunk/Open-ILS/include/openils/oils_buildq.h
===================================================================
--- trunk/Open-ILS/include/openils/oils_buildq.h	2010-06-28 15:25:07 UTC (rev 16820)
+++ trunk/Open-ILS/include/openils/oils_buildq.h	2010-06-28 15:43:28 UTC (rev 16821)
@@ -173,7 +173,6 @@
 	EXP_CAST,
 	EXP_COLUMN,
 	EXP_EXIST,
-	EXP_FIELD,
 	EXP_FUNCTION,
 	EXP_IN,
 	EXP_ISNULL,
@@ -196,7 +195,7 @@
 	char*       table_alias;
 	char*       column_name;
 	Expression* left_operand;
-	char*       op;
+	char*       op;                 // Not called "operator" because that's a keyword in C++
 	Expression* right_operand;
 	int         subquery_id;
 	StoredQ*    subquery;

Modified: trunk/Open-ILS/src/c-apps/buildSQL.c
===================================================================
--- trunk/Open-ILS/src/c-apps/buildSQL.c	2010-06-28 15:25:07 UTC (rev 16820)
+++ trunk/Open-ILS/src/c-apps/buildSQL.c	2010-06-28 15:43:28 UTC (rev 16821)
@@ -728,13 +728,6 @@
 				buffer_add_char( state->sql, ')' );
 			}
 			break;
-		case EXP_FIELD :
-			if( expr->negate )
-				buffer_add( state->sql, "NOT " );
-
-			sqlAddMsg( state, "Field expressions not yet supported" );
-			state->error = 1;
-			break;
 		case EXP_FUNCTION :
 			buildFunction( state, expr );
 			break;
@@ -956,6 +949,11 @@
 	if( expr->negate )
 		buffer_add( state->sql, "NOT " );
 
+	// If a subfield is specified, the function call
+	// needs an extra layer of parentheses
+	if( expr->column_name )
+		buffer_add_char( state->sql, '(' );
+
 	// We rely on the input side to ensure that the function name is available
 	buffer_add( state->sql, expr->function_name );
 	buffer_add_char( state->sql, '(' );
@@ -964,6 +962,13 @@
 	buildSeries( state, expr->subexp_list, NULL );
 
 	buffer_add_char( state->sql, ')' );
+
+	if( expr->column_name ) {
+		// Add the name of the subfield
+		buffer_add( state->sql, ").\"" );
+		buffer_add( state->sql, expr->column_name );
+		buffer_add_char( state->sql, '\"' );
+	}
 }
 
 /**

Modified: trunk/Open-ILS/src/c-apps/oils_storedq.c
===================================================================
--- trunk/Open-ILS/src/c-apps/oils_storedq.c	2010-06-28 15:25:07 UTC (rev 16820)
+++ trunk/Open-ILS/src/c-apps/oils_storedq.c	2010-06-28 15:43:28 UTC (rev 16821)
@@ -1540,8 +1540,6 @@
 		type = EXP_COLUMN;
 	else if( !strcmp( type_str, "xex" ))
 		type = EXP_EXIST;
-	else if( !strcmp( type_str, "xfld" ))
-		type = EXP_FIELD;
 	else if( !strcmp( type_str, "xfunc" ))
 		type = EXP_FUNCTION;
 	else if( !strcmp( type_str, "xin" ))



More information about the open-ils-commits mailing list