From c9a677a7a5230fd78f61aabec7d22739ef55ef58 Mon Sep 17 00:00:00 2001 From: scottmk Date: Thu, 10 Jun 2010 14:35:01 +0000 Subject: [PATCH] Fix a pcrud bug. Create method wasn't working because we were foolishly trying to fetch the record that hadn't been created yet, in order to test its ownership. M Open-ILS/src/c-apps/oils_sql.c git-svn-id: svn://svn.open-ils.org/ILS/trunk@16649 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/src/c-apps/oils_sql.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Open-ILS/src/c-apps/oils_sql.c b/Open-ILS/src/c-apps/oils_sql.c index 4158693272..56397e6ca4 100644 --- a/Open-ILS/src/c-apps/oils_sql.c +++ b/Open-ILS/src/c-apps/oils_sql.c @@ -1267,16 +1267,18 @@ static int verifyObjectPCRUD ( osrfMethodContext* ctx, const jsonObject* obj ) osrfHash* class = osrfHashGet( method_metadata, "class" ); const char* method_type = osrfHashGet( method_metadata, "methodtype" ); - // Set fetch to 1 in all cases, meaning that for local or foreign contexts we will - // always do another lookup of the current row, even if we already have a row image, - // because the row image in hand may not include the foreign key(s) that we need. + // Set fetch to 1 in all cases except for inserts, meaning that for local or foreign + // contexts we will do another lookup of the current row, even if we already have a + // previously fetched row image, because the row image in hand may not include the + // foreign key(s) that we need. // This is a quick fix with a bludgeon. There are ways to avoid the extra lookup, // but they aren't implemented yet. - //int fetch = 0; - int fetch = 1; + + int fetch = 0; if( *method_type == 's' || *method_type == 'i' ) { method_type = "retrieve"; // search and id_list are equivalent to retrieve for this + fetch = 1; } else if( *method_type == 'u' || *method_type == 'd' ) { fetch = 1; // MUST go to the db for the object for update and delete } -- 2.43.2