LP#1311467: fix heading validation in bib editor
authorGalen Charlton <gmc@esilibrary.com>
Wed, 23 Apr 2014 05:45:43 +0000 (01:45 -0400)
committerMike Rylander <mrylander@gmail.com>
Wed, 23 Apr 2014 12:10:05 +0000 (08:10 -0400)
This patch fixes a regression whereby clicking the validate button
in the bib editor would result in no headings getting checked.

In the process, it enables 'startwith' to be used as a JSON query
operator for all types of predicates, not just the results of
transformed values.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Signed-off-by: Mike Rylander <mrylander@gmail.com>
Open-ILS/examples/fm_IDL.xml
Open-ILS/src/c-apps/oils_sql.c

index adfcd2e..f318da8 100644 (file)
@@ -2352,6 +2352,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
                        <field name="source" />
                        <field reporter:label="Control Set" name="control_set" reporter:datatype="link"/>
                        <field reporter:label="Owner" name="owner"  reporter:datatype="org_unit"/>
+                       <field name="heading" />
+                       <field name="simple_heading" />
                        <field name="fixed_fields" oils_persist:virtual="true" reporter:datatype="link"/>
                        <field name="notes" oils_persist:virtual="true" reporter:datatype="link"/>
                        <field name="bib_links" oils_persist:virtual="true" reporter:datatype="link"/>
index e72bb49..dac5d8c 100644 (file)
@@ -2656,14 +2656,23 @@ static char* searchFunctionPredicate( const char* class_alias, osrfHash* field,
        if( !val )
                return NULL;
 
+       const char* right_percent = "";
+       const char* real_op       = op;
+
+       if( !strcasecmp( op, "startwith") ) {
+               real_op = "like";
+               right_percent = "|| '%'";
+       }
+
        growing_buffer* sql_buf = buffer_init( 32 );
        buffer_fadd(
                sql_buf,
-               "\"%s\".%s %s %s",
+               "\"%s\".%s %s %s%s",
                class_alias,
                osrfHashGet( field, "name" ),
-               op,
-               val
+               real_op,
+               val,
+               right_percent
        );
 
        free( val );
@@ -2899,8 +2908,16 @@ static char* searchSimplePredicate( const char* op, const char* class_alias,
                        op = "IS";
        }
 
+       const char* right_percent = "";
+       const char* real_op       = op;
+
+       if( !strcasecmp( op, "startwith") ) {
+               real_op = "like";
+               right_percent = "|| '%'";
+       }
+
        growing_buffer* sql_buf = buffer_init( 32 );
-       buffer_fadd( sql_buf, "\"%s\".%s %s %s", class_alias, osrfHashGet(field, "name"), op, val );
+       buffer_fadd( sql_buf, "\"%s\".%s %s %s%s", class_alias, osrfHashGet(field, "name"), real_op, val, right_percent );
        char* pred = buffer_release( sql_buf );
 
        free( val );