glom r1867 - in trunk: . glom glom/libglom glom/libglom/data_structure glom/mode_data glom/reports



Author: murrayc
Date: Fri Jan 30 14:19:18 2009
New Revision: 1867
URL: http://svn.gnome.org/viewvc/glom?rev=1867&view=rev

Log:
2009-01-30  Murray Cumming  <murrayc murrayc com>

Added some TODO comments where we would like to use SQL parameters 
instead of Field::sql(), if we can figure out how to do that for 
fragments of SQL, or how to refactor the code to parse the whole 
SQL query at once.

Modified:
   trunk/ChangeLog
   trunk/glom/base_db.cc
   trunk/glom/libglom/data_structure/field.cc
   trunk/glom/libglom/data_structure/field.h
   trunk/glom/libglom/utils.cc
   trunk/glom/mode_data/box_data.cc
   trunk/glom/mode_data/box_data_calendar_related.cc
   trunk/glom/mode_data/box_data_details.cc
   trunk/glom/reports/report_builder.cc

Modified: trunk/glom/base_db.cc
==============================================================================
--- trunk/glom/base_db.cc	(original)
+++ trunk/glom/base_db.cc	Fri Jan 30 14:19:18 2009
@@ -1849,6 +1849,7 @@
 
       if(use_this_field)
       {
+        //TODO: Use a SQL parameter instead of using sql().
         strClausePart = "\"" + table_name + "\".\"" + field->get_name() + "\" " + field->sql_find_operator() + " " +  field->sql_find(quick_search);
       }
 
@@ -3163,7 +3164,8 @@
  
     //std::cout << "extra_join where_clause_to_key_field=" << where_clause_to_key_field->get_name() << std::endl;
   }
-  // TODO: Where is this used? Should we use parameters for this query?
+
+  // TODO: Where is this used? Should we use parameters for this query instead of sql()?
   if(where_clause_to_key_field)
     found_set.m_where_clause = "\"" + where_clause_to_table_name + "\".\"" + relationship->get_to_field() + "\" = " + where_clause_to_key_field->sql(foreign_key_value);
 }

Modified: trunk/glom/libglom/data_structure/field.cc
==============================================================================
--- trunk/glom/libglom/data_structure/field.cc	(original)
+++ trunk/glom/libglom/data_structure/field.cc	Fri Jan 30 14:19:18 2009
@@ -747,7 +747,7 @@
 
 Glib::RefPtr<Gnome::Gda::Holder> Field::get_holder(const Glib::ustring& name) const
 {
-  Glib::ustring real_name = name.empty() ? get_name() : name;
+  const Glib::ustring real_name = name.empty() ? get_name() : name;
   Glib::RefPtr<Gnome::Gda::Holder> holder = Gnome::Gda::Holder::create(get_gda_g_type(),
                                                                        real_name);
   holder->set_value_as_value(get_data());
@@ -763,7 +763,7 @@
 
 Glib::ustring Field::get_gda_holder_string(const Glib::ustring& name) const
 {
-  Glib::ustring real_name = name.empty() ? get_name() : name;
+  const Glib::ustring real_name = name.empty() ? get_name() : name;
   return "##" + real_name + "::" + get_gda_type();
 }
 

Modified: trunk/glom/libglom/data_structure/field.h
==============================================================================
--- trunk/glom/libglom/data_structure/field.h	(original)
+++ trunk/glom/libglom/data_structure/field.h	Fri Jan 30 14:19:18 2009
@@ -161,8 +161,17 @@
   Glib::ustring get_sql_type() const;
   Glib::ustring get_gda_type() const;
   GType get_gda_g_type() const;
+
+  /** TODO: Documentation.
+   */
   Glib::RefPtr<Gnome::Gda::Holder> get_holder(const Glib::ustring& name = Glib::ustring()) const;
+
+  /** TODO: Documentation.
+   */
   Glib::RefPtr<Gnome::Gda::Holder> get_holder(const Gnome::Gda::Value& value, const Glib::ustring& name = Glib::ustring()) const;
+
+  /** TODO: Documentation.
+   */
   Glib::ustring get_gda_holder_string(const Glib::ustring& name = Glib::ustring()) const;
 
   /** Escape the value so that it can be used in a SQL command.

Modified: trunk/glom/libglom/utils.cc
==============================================================================
--- trunk/glom/libglom/utils.cc	(original)
+++ trunk/glom/libglom/utils.cc	Fri Jan 30 14:19:18 2009
@@ -423,6 +423,7 @@
 {
   if(!Conversions::value_is_empty(key_value)) //If there is a record to show:
   {
+    //TODO: Use a SQL parameter instead of using sql():
     const Glib::ustring where_clause = "\"" + table_name + "\".\"" + key_field->get_name() + "\" = " + key_field->sql(key_value);
     return Utils::build_sql_select_with_where_clause(table_name, fieldsToGet, where_clause);
   }

Modified: trunk/glom/mode_data/box_data.cc
==============================================================================
--- trunk/glom/mode_data/box_data.cc	(original)
+++ trunk/glom/mode_data/box_data.cc	Fri Jan 30 14:19:18 2009
@@ -109,6 +109,7 @@
 
         if(use_this_field)
         {
+          //TODO: Use a SQL parameter instead of using sql_find().
           strClausePart = "\"" + m_table_name + "\".\"" + field->get_name() + "\" " + field->sql_find_operator() + " " +  field->sql_find(data); //% is mysql wildcard for 0 or more characters.
         }
       }

Modified: trunk/glom/mode_data/box_data_calendar_related.cc
==============================================================================
--- trunk/glom/mode_data/box_data_calendar_related.cc	(original)
+++ trunk/glom/mode_data/box_data_calendar_related.cc	Fri Jan 30 14:19:18 2009
@@ -169,6 +169,7 @@
 
     //Add an AND to the existing where clause, to get only records within these dates, if any:
     sharedptr<const Field> date_field = derived_portal->get_date_field();
+    //TODO: Use a SQL parameter instead of using sql().
     const Glib::ustring extra_where_clause = "\"" + where_clause_to_table_name + "\".\"" + date_field->get_name() + "\""
       " BETWEEN DATE " + date_field->sql(date_start_value) + 
       " AND DATE " + date_field->sql(date_end_value);

Modified: trunk/glom/mode_data/box_data_details.cc
==============================================================================
--- trunk/glom/mode_data/box_data_details.cc	(original)
+++ trunk/glom/mode_data/box_data_details.cc	Fri Jan 30 14:19:18 2009
@@ -147,7 +147,6 @@
 {
   m_primary_key_value = value;
   set_found_set_from_primary_key_value();
-  //std::cout << "Box_Data_Details::set_primary_key_value(): m_primary_key_value=" << m_field_primary_key->sql(m_primary_key_value) << std::endl;
 }
 
 void Box_Data_Details::set_found_set_from_primary_key_value()
@@ -157,6 +156,7 @@
 
   if(!m_primary_key_value.is_null())
   {
+    //TODO: Use a SQL parameter instead of using sql().
     m_found_set.m_where_clause = "\"" + m_table_name + "\".\"" + m_field_primary_key->get_name() + 
       "\" = " + m_field_primary_key->sql(m_primary_key_value);
     //std::cout << "  DEBUG: Box_Data_Details::set_primary_key_value(): m_found_set.m_where_clause = " << m_found_set.m_where_clause << std::endl;

Modified: trunk/glom/reports/report_builder.cc
==============================================================================
--- trunk/glom/reports/report_builder.cc	(original)
+++ trunk/glom/reports/report_builder.cc	Fri Jan 30 14:19:18 2009
@@ -200,6 +200,7 @@
         nodeGroupBy->set_attribute("group_value",
           Conversions::get_text_for_gda_value(field_group_by->get_glom_type(), group_value, field_group_by->get_formatting_used().m_numeric_format) );
 
+        //TODO: Use a SQL parameter instead of using sql().
         Glib::ustring where_clause = "(\"" + group_field_table_name + "\".\"" + field_group_by->get_name() + "\" = " + field_group_by->get_full_field_details()->sql(group_value) + ")";
         if(!found_set_parent.m_where_clause.empty())
           where_clause += " AND (" + found_set_parent.m_where_clause + ")";



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