glom r1961 - in trunk: . glom/mode_data



Author: murrayc
Date: Fri Mar  6 10:00:09 2009
New Revision: 1961
URL: http://svn.gnome.org/viewvc/glom?rev=1961&view=rev

Log:
2009-03-06  Murray Cumming  <murrayc murrayc com>

* glom/mode_data/box_data_portal.cc: get_suitable_record_to_view_details():
Use the correct primary key of the related table. This fixes navigation 
on the Small Business Example, on the invoice lines, which goes to the 
product record.

Modified:
   trunk/ChangeLog
   trunk/glom/mode_data/box_data_portal.cc

Modified: trunk/glom/mode_data/box_data_portal.cc
==============================================================================
--- trunk/glom/mode_data/box_data_portal.cc	(original)
+++ trunk/glom/mode_data/box_data_portal.cc	Fri Mar  6 10:00:09 2009
@@ -297,7 +297,12 @@
   type_vecLayoutFields fieldsToGet;
   fieldsToGet.push_back(layout_item);
 
-  const Glib::ustring query = Utils::build_sql_select_with_key(m_portal->get_table_used(Glib::ustring() /* not relevant */), fieldsToGet, get_key_field(), primary_key_value);
+  //For instance "invoice_line_id" if this is a portal to an "invoice_lines" table:
+  const Glib::ustring related_table = m_portal->get_table_used(Glib::ustring() /* not relevant */);
+  sharedptr<const Field> key_field = get_field_primary_key_for_table(related_table);
+  //std::cout << "DEBUG: related table=" << related_table << ", whose primary_key=" << key_field->get_name() << std::endl;
+
+  const Glib::ustring query = Utils::build_sql_select_with_key(related_table, fieldsToGet, key_field, primary_key_value);
   Glib::RefPtr<Gnome::Gda::DataModel> data_model = query_execute_select(query);
 
 
@@ -321,7 +326,14 @@
   else
   {
     value_found = false;
-    std::cout << "debug: Box_Data_Portal::get_suitable_record_to_view_details(): SQL query returned no suitable primary key." << std::endl;
+
+    std::cout << "DEBUG: Box_Data_Portal::get_suitable_record_to_view_details(): SQL query returned no suitable primary key. table=" 
+      << related_table  
+      << ", field=" << layout_item->get_layout_display_name() 
+      << ", key_field=" key_field->get_name()
+      << ", primary_key_value=" << primary_key_value.to_string() << std::endl;
+
+    std::cout << "  DEBUG: SQL was: " << query << std::endl;
   }
 
   if(!value_found)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]