[glom] Utils::get_find_where_clause_quick(): Handle an empty value properly.



commit 318de3692517e1c64b8d5bdc93f10248eac21f05
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 c0b63a1..b9816a9 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 83e92ee..80b1a22 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 004f513..dd74f5d 100644
--- a/glom/libglom/utils.cc
+++ b/glom/libglom/utils.cc
@@ -1103,6 +1103,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]