[glom/glom-1-20] Utils::get_find_where_clause_quick(): Handle an empty value properly.



commit c31e2cbf22b8108397a69c73ee249181e4cd42e5
Author: Murray Cumming <murrayc murrayc com>
Date:   Mon Mar 5 10:27:54 2012 +0100

    Utils::get_find_where_clause_quick(): Handle an empty value properly.
    
    	* glom/libglom/utils.cc: get_find_where_clause_quick():
    	Handle an empty quick_search value properly, returning an empty
    	where clause.

 ChangeLog                                          |    8 ++++++++
 .../layout/report_parts/layoutitem_groupby.h       |    1 +
 glom/libglom/utils.cc                              |    9 +++++++++
 3 files changed, 18 insertions(+), 0 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index cf0029f..3b1f24d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2012-03-05  Murray Cumming  <murrayc murrayc com>
+
+	Utils::get_find_where_clause_quick(): Handle an empty value properly.
+
+	* glom/libglom/utils.cc: get_find_where_clause_quick():
+	Handle an empty quick_search value properly, returning an empty
+	where clause.
+
 2012-03-03  Ben Konrath  <ben bagu org>
 
 	Remove empty group in the Lesson Planner example file.
diff --git a/glom/libglom/data_structure/layout/report_parts/layoutitem_groupby.h b/glom/libglom/data_structure/layout/report_parts/layoutitem_groupby.h
index c97cbff..6fa8453 100644
--- a/glom/libglom/data_structure/layout/report_parts/layoutitem_groupby.h
+++ b/glom/libglom/data_structure/layout/report_parts/layoutitem_groupby.h
@@ -67,6 +67,7 @@ public:
   virtual Glib::ustring get_part_type_name() const;
   virtual Glib::ustring get_report_part_id() const;
 
+  //TODO: Add get/set methods for this:
   sharedptr<LayoutGroup> m_group_secondary_fields; //For instance, show a contact name as well as the contact ID that we group by.
 
   type_list_sort_fields m_fields_sort_by;
diff --git a/glom/libglom/utils.cc b/glom/libglom/utils.cc
index 392f535..9f57f09 100644
--- a/glom/libglom/utils.cc
+++ b/glom/libglom/utils.cc
@@ -1099,6 +1099,15 @@ std::string Utils::sqlbuilder_get_full_query(
 
 Gnome::Gda::SqlExpr Utils::get_find_where_clause_quick(const Document* document, const Glib::ustring& table_name, const Gnome::Gda::Value& quick_search)
 {
+  if(table_name.empty())
+  {
+    std::cerr << G_STRFUNC << ": table_name is empty." << std::endl;
+    return Gnome::Gda::SqlExpr();
+  }
+
+  if(Conversions::value_is_empty(quick_search))
+    return Gnome::Gda::SqlExpr();
+  
   Glib::RefPtr<Gnome::Gda::SqlBuilder> builder =
     Gnome::Gda::SqlBuilder::create(Gnome::Gda::SQL_STATEMENT_SELECT);
   builder->select_add_target(table_name);



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