[glom] Field: Remove get_holder().
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glom] Field: Remove get_holder().
- Date: Thu, 29 Mar 2012 14:19:55 +0000 (UTC)
commit d249bf7a058b78656c12f91c59449b2917f83087
Author: Murray Cumming <murrayc murrayc com>
Date: Thu Mar 29 16:18:39 2012 +0200
Field: Remove get_holder().
* glom/libglom/data_structure/field.[h|cc]:
* glom/libglom/python_embed/py_glom_record.cc:
* glom/mode_data/datawidget/treemodel_db.cc: Replace or remove use
of Field::get_holder().
ChangeLog | 9 +++++++++
glom/libglom/data_structure/field.cc | 26 --------------------------
glom/libglom/data_structure/field.h | 4 ----
glom/libglom/python_embed/py_glom_record.cc | 22 ----------------------
glom/mode_data/datawidget/treemodel_db.cc | 26 +++++++++++++++-----------
5 files changed, 24 insertions(+), 63 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 13d7609..9a33666 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
2012-03-29 Murray Cumming <murrayc murrayc com>
+ Field: Remove get_holder().
+
+ * glom/libglom/data_structure/field.[h|cc]:
+ * glom/libglom/python_embed/py_glom_record.cc:
+ * glom/mode_data/datawidget/treemodel_db.cc: Replace or remove use
+ of Field::get_holder().
+
+2012-03-29 Murray Cumming <murrayc murrayc com>
+
ConnectionPool: create_database(): Take a progress slot.
* glom/libglom/connectionpool.[h|cc]::
diff --git a/glom/libglom/data_structure/field.cc b/glom/libglom/data_structure/field.cc
index dbc9e6e..a2fbd66 100644
--- a/glom/libglom/data_structure/field.cc
+++ b/glom/libglom/data_structure/field.cc
@@ -553,32 +553,6 @@ Glib::ustring Field::get_gda_type_name() const
return g_type_name( m_field_info->get_g_type());
}
-Glib::RefPtr<Gnome::Gda::Holder> Field::get_holder(const Gnome::Gda::Value& value, const Glib::ustring& name) const
-{
- const Glib::ustring real_name = name.empty() ? get_name() : name;
-
- const GType gtype = value.get_value_type();
-
- /*
- const GType field_type = m_field_info->get_g_type();
- if(m_field_info->get_g_type() != gtype)
- {
- // This currently happens with SQLite for pictures. The value type is
- // GdaBinary, but the field type is GdaBlob. This is not an optimal
- // solution this way. We should maybe check fallback types here, or
- // investigate why the field type is not GdaBinary as well.
- // Maybe get_gda_type_for_glom_type() should already return fallback
- // types if necessary.
- // Reply from murray: sqlite returns GdaBlob by default, and that should be OK. Is this causing a problem?
- std::cout << "debug: " << G_STRFUNC << ": Field type " << g_type_name(field_type) << " and value type " << g_type_name(gtype) << " don't match." << std::endl;
- }
- */
-
- Glib::RefPtr<Gnome::Gda::Holder> holder = Gnome::Gda::Holder::create(gtype, real_name);
- holder->set_value_as_value(value);
- return holder;
-}
-
/// Ignores any part of FieldAttributes that libgda does not properly fill.
bool Field::field_info_from_database_is_equal(const Glib::RefPtr<const Gnome::Gda::Column>& field)
{
diff --git a/glom/libglom/data_structure/field.h b/glom/libglom/data_structure/field.h
index f45e74f..635fdc5 100644
--- a/glom/libglom/data_structure/field.h
+++ b/glom/libglom/data_structure/field.h
@@ -159,10 +159,6 @@ public:
Glib::ustring get_sql_type() const;
Glib::ustring get_gda_type_name() const;
- //TODO: Shouldn't this be called get_gda_holder_name()?
- /// A convenience when using parameters with a libgda SQL query.
- Glib::RefPtr<Gnome::Gda::Holder> get_holder(const Gnome::Gda::Value& value, const Glib::ustring& name = Glib::ustring()) const;
-
/** Escape and quote the value so that it can be used in a SQL command.
*/
Glib::ustring sql(const Gnome::Gda::Value& value, const Glib::RefPtr<Gnome::Gda::Connection>& connection) const;
diff --git a/glom/libglom/python_embed/py_glom_record.cc b/glom/libglom/python_embed/py_glom_record.cc
index 5ae5b62..a47fa7f 100644
--- a/glom/libglom/python_embed/py_glom_record.cc
+++ b/glom/libglom/python_embed/py_glom_record.cc
@@ -181,10 +181,6 @@ void PyGlomRecord::setitem(const boost::python::object& key, const boost::python
return;
}
- Glib::RefPtr<Gnome::Gda::Set> params = Gnome::Gda::Set::create();
- params->add_holder(field->get_holder(field_value));
- params->add_holder(m_key_field->get_holder(m_key_field_value));
-
Glib::RefPtr<Gnome::Gda::SqlBuilder> builder =
Gnome::Gda::SqlBuilder::create(Gnome::Gda::SQL_STATEMENT_UPDATE);
builder->set_table(m_table_name);
@@ -210,25 +206,7 @@ void PyGlomRecord::setitem(const boost::python::object& key, const boost::python
if(!updated)
{
- Glib::ustring failed_query;
-
std::cerr << G_STRFUNC << ": UPDATE failed." << std::endl;
- /*
- if(stmt)
- failed_query = stmt->to_sql(params); //this throws too.
- else
- failed_query = strQuery;
-
- try
- {
- std::cerr << " with SQL query: " << failed_query << std::endl;
- }
- catch(const Glib::Exception& ex)
- {
- std::cerr << " query string could not be converted to std::cerr" << std::endl;
- }
- */
-
}
//TODO: Do dependent calculations and lookups. Or just do them for all fields for this record when finishing the script?
diff --git a/glom/mode_data/datawidget/treemodel_db.cc b/glom/mode_data/datawidget/treemodel_db.cc
index 4967e30..39c4798 100644
--- a/glom/mode_data/datawidget/treemodel_db.cc
+++ b/glom/mode_data/datawidget/treemodel_db.cc
@@ -70,25 +70,29 @@ void DbTreeModelRow::fill_values_if_necessary(DbTreeModel& model, int row)
const int cols_count = model.m_data_model_columns_count;
for(int i = 0; i < cols_count; ++i)
{
- //TODO: Use iter->get_value_at(i) with try/catch instead when we can depend on libgdamm >= 4.99.4.2
- Glib::RefPtr<const Gnome::Gda::Holder> holder = iter->get_holder_for_field(i);
- if(holder)
- m_db_values[i] = holder->get_value();
- else
+ try
+ {
+ m_db_values[i] = iter->get_value_at(i);
+ }
+ catch(const Glib::Error& ex)
{
// This is quite possible, for example for unset dates. jhs
- //std::cerr << G_STRFUNC << ": NULL Gnome::Gda::Holder for field=" << i << std::endl;
+ std::cerr << G_STRFUNC << ": get_value_at() failed for column=" << i << ", with exception: " << ex.what() << std::endl;
}
//std::cout << " debug: col=" << i << ", GType=" << m_db_values[i].get_value_type() << ", string=" << m_db_values[i].to_string() << std::endl;
}
//TODO: Use iter->get_value_at(i) with try/catch instead when we can depend on libgdamm >= 4.99.4.2
- Glib::RefPtr<const Gnome::Gda::Holder> holder = iter->get_holder_for_field(model.m_column_index_key);
- if(holder)
- m_key = holder->get_value(); //TODO_gda: Why not just use get_value_at()?
- else
- std::cerr << G_STRFUNC << ": NULL Gnome::Gda::Holder for key field" << std::endl;
+ try
+ {
+ m_key = iter->get_value_at(model.m_column_index_key);
+ }
+ catch(const Glib::Error& ex)
+ {
+ // This is quite possible, for example for unset dates. jhs
+ std::cerr << G_STRFUNC << ": get_value_at() failed for model.m_column_index_key=" << model.m_column_index_key << ", with exception: " << ex.what() << std::endl;
+ }
m_extra = false;
m_removed = false;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]