[glom/modification: 28/33] In progress. Hit a table_name problem.
- From: Murray Cumming <murrayc src gnome org>
- To: svn-commits-list gnome org
- Subject: [glom/modification: 28/33] In progress. Hit a table_name problem.
- Date: Thu, 4 Jun 2009 17:01:40 -0400 (EDT)
commit d00e9e886d9fe4f0cc01485408b07e58799e706f
Author: Murray Cumming <murrayc murrayc com>
Date: Sun May 10 16:38:34 2009 +0200
In progress. Hit a table_name problem.
---
glom/base_db.cc | 234 +++++++++++++++++++++++++++++
glom/base_db.h | 11 ++
glom/base_db_table_data.cc | 288 ++----------------------------------
glom/base_db_table_data.h | 7 +-
glom/dialog_import_csv_progress.cc | 4 +-
glom/mode_data/box_data_details.cc | 6 +-
6 files changed, 261 insertions(+), 289 deletions(-)
diff --git a/glom/base_db.cc b/glom/base_db.cc
index 54b86cd..41c92a9 100644
--- a/glom/base_db.cc
+++ b/glom/base_db.cc
@@ -1589,6 +1589,240 @@ Glib::RefPtr<Gnome::Gda::Connection> Base_DB::get_connection()
return gda_connection;
}
+
+/** A predicate for use with std::find_if() to find a std::pair whose
+ * first item is the same field.
+ */
+class predicate_pair_has_field
+{
+public:
+ predicate_pair_has_field(const sharedptr<const Field>& field)
+ {
+ m_field = field;
+ }
+
+ template <class T_Second>
+ bool operator() (const std::pair<sharedptr<Field>, T_Second>& element)
+ {
+ sharedptr<Field> field = element.first;
+
+ if(!field && !m_field)
+ return true;
+
+ if(!field || !m_field)
+ return false;
+
+ //TODO: Check more than just the name:
+ return (m_field->get_name() == field->get_name());
+ }
+
+private:
+ sharedptr<const Field> m_field;
+};
+
+bool Base_DB::record_new(const Glib::ustring& table_name, const Gnome::Gda::Value& primary_key_value, const type_field_values& field_values)
+{
+ sharedptr<const Field> fieldPrimaryKey = get_field_primary_key_for_table(table_name);
+ const Glib::ustring primary_key_name = fieldPrimaryKey->get_name();
+
+ type_field_values field_values_plus_others = field_values;
+
+ //Add values for all fields that default to something, not just the shown ones:
+ //For instance, we must always add the primary key, and fields with default/calculated/lookup values:
+ type_vec_fields all_fields = get_fields_for_table(table_name);
+ for(type_vec_fields::const_iterator iter = all_fields.begin(); iter != all_fields.end(); ++iter)
+ {
+ //TODO: Search for the non-related field with the name, not just the field with the name:
+ sharedptr<Field> field = *iter;
+ type_field_values::const_iterator iterFind = std::find_if(field_values_plus_others.begin(), field_values_plus_others.end(), predicate_pair_has_field(field));
+ if(iterFind == field_values_plus_others.end())
+ {
+ //The actual appropriate field value will be filled in below:
+ field_values_plus_others.push_back( type_field_and_value(field, Gnome::Gda::Value()) );
+ }
+ }
+
+
+ Document* document = get_document();
+ ConnectionPool* connection_pool = ConnectionPool::get_instance();
+
+ //Calculate any necessary field values and remember them:
+ for(type_field_values::iterator iter = field_values_plus_others.begin(); iter != field_values_plus_others.end(); ++iter)
+ {
+ const sharedptr<const Field>& field = iter->first;
+ if(!field)
+ continue;
+
+ //If the caller supplied a field value then use it:
+ Gnome::Gda::Value value = iter->second;
+
+ if(Conversions::value_is_empty(value)) //This deals with empty strings too.
+ {
+ if(field) //TODO: Remove this check: we already check it above.
+ {
+ //If the default value should be calculated, then calculate it:
+ if(field->get_has_calculation())
+ {
+ const Glib::ustring calculation = field->get_calculation();
+ const type_map_fields field_values = get_record_field_values_for_calculation(table_name, fieldPrimaryKey, primary_key_value);
+
+ //We need the connection when we run the script, so that the script may use it.
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
+ // TODO: Is this function supposed to throw an exception?
+ sharedptr<SharedConnection> sharedconnection = connect_to_server(App_Glom::get_application());
+#else
+ std::auto_ptr<ExceptionConnection> error;
+ sharedptr<SharedConnection> sharedconnection = connect_to_server(App_Glom::get_application(), error);
+ if(error.get() == NULL)
+ {
+ // Don't evaluate function on error
+#endif // GLIBMM_EXCEPTIONS_ENABLED
+
+ const Gnome::Gda::Value value = glom_evaluate_python_function_implementation(field->get_glom_type(), calculation, field_values, document, table_name, sharedconnection->get_gda_connection());
+ iter->second = value;
+#ifndef GLIBMM_EXCEPTIONS_ENABLED
+ }
+#endif // !GLIBMM_EXCEPTIONS_ENABLED
+ }
+
+ //Use default values (These are also specified in postgres as part of the field definition,
+ //so we could theoretically just not specify it here.)
+ //TODO_Performance: Add has_default_value()?
+ if(Conversions::value_is_empty(value))
+ {
+ const Gnome::Gda::Value default_value = field->get_default_value();
+ if(!Conversions::value_is_empty(default_value))
+ {
+ iter->second = default_value;
+ }
+ }
+ }
+ }
+ }
+
+ //Get all entered field name/value pairs:
+ Glib::ustring strNames;
+ Glib::ustring strValues;
+
+ //Avoid specifying the same field twice:
+ typedef std::map<Glib::ustring, bool> type_map_added;
+ type_map_added map_added;
+ Glib::RefPtr<Gnome::Gda::Set> params = Gnome::Gda::Set::create();
+
+ for(type_field_values::const_iterator iter = field_values_plus_others.begin(); iter != field_values_plus_others.end(); ++iter)
+ {
+ sharedptr<Field> field = iter->first;
+ //sharedptr<LayoutItem_Field> layout_item = *iter;
+ const Glib::ustring field_name = field->get_name();
+ if(true) //!layout_item->get_has_relationship_name()) //TODO: Allow people to add a related record also by entering new data in a related field of the related record.
+ {
+ type_map_added::const_iterator iterFind = map_added.find(field_name);
+ if(iterFind == map_added.end()) //If it was not added already
+ {
+ Gnome::Gda::Value value;
+
+ if(field) //TODO: Check above instead.
+ {
+ //Use the specified (generated) primary key value, if there is one:
+ if(primary_key_name == field_name && !Conversions::value_is_empty(primary_key_value))
+ {
+ value = primary_key_value;
+ }
+ //Handle the special creation fields:
+ //TODO_performance: Avoid these string comparisons for each field:
+ else if(field_name == GLOM_STANDARD_DEFAULT_FIELD_CREATION_DATE)
+ {
+ value = Utils::get_current_date_utc_as_value();
+ }
+ else if(field_name == GLOM_STANDARD_DEFAULT_FIELD_CREATION_TIME)
+ {
+ value = Utils::get_current_time_utc_as_value();
+ }
+ else if(field_name == GLOM_STANDARD_DEFAULT_FIELD_CREATION_USER)
+ {
+ value = Gnome::Gda::Value(connection_pool->get_user());
+ }
+
+ /* //TODO: This would be too many small queries when adding one record.
+ //Check whether the value meets uniqueness constraints:
+ if(field->get_primary_key() || field->get_unique_key())
+ {
+ if(!get_field_value_is_unique(table_name, layout_item, value))
+ {
+ //Ignore this field value. TODO: Warn the user about it.
+ }
+ }
+ */
+ if(!value.is_null())
+ {
+ sharedptr<LayoutItem_Field> layout_item = sharedptr<LayoutItem_Field>::create();
+ layout_item->set_full_field_details(field);
+ set_entered_field_data(layout_item, value);
+
+ if(!strNames.empty())
+ {
+ strNames += ", ";
+ strValues += ", ";
+ }
+
+ strNames += "\"" + field_name + "\"";
+ strValues += field->get_gda_holder_string();
+ const Glib::RefPtr<Gnome::Gda::Holder> holder = field->get_holder(value);
+ params->add_holder(holder);
+
+ map_added[field_name] = true;
+ }
+ }
+ }
+ }
+ }
+
+ //Put it all together to create the record with these field values:
+ if(!strNames.empty() && !strValues.empty())
+ {
+ const Glib::ustring strQuery = "INSERT INTO \"" + table_name + "\" (" + strNames + ") VALUES (" + strValues + ")";
+ const bool test = query_execute(strQuery, params);
+ if(!test)
+ std::cerr << "Box_Data::record_new(): INSERT failed." << std::endl;
+ else
+ {
+ //TODO: Previously needed by by DbAddDel::user_changed(). Is that still true?
+ //Gtk::TreeModel::iterator row = get_row_selected(); //Null and ignored for details views.
+ //set_primary_key_value(row, primary_key_value); //Needed by DbAddDel::user_changed().
+
+ //Update any lookups, related fields, or calculations:
+ for(type_field_values::const_iterator iter = field_values_plus_others.begin(); iter != field_values_plus_others.end(); ++iter)
+ {
+ //sharedptr<const LayoutItem_Field> layout_item = *iter;
+
+ const Gnome::Gda::Value& field_value = iter->second;
+
+ sharedptr<Field> field = iter->first;
+ sharedptr<LayoutItem_Field> layout_item = sharedptr<LayoutItem_Field>::create();
+ layout_item->set_full_field_details(field);
+ LayoutFieldInRecord field_in_record(layout_item, table_name, fieldPrimaryKey, primary_key_value);
+
+ //TODO: This is meaningless for this any-table_name version of this function:
+ Gtk::TreeModel::iterator row = get_row_selected(); //Null and ignored for details views.
+
+ //Get-and-set values for lookup fields, if this field triggers those relationships:
+ do_lookups(field_in_record, row, field_value);
+
+ //Update related fields, if this field is used in the relationship:
+ refresh_related_fields(field_in_record, row, field_value);
+
+ //TODO: Put the inserted row into result, somehow? murrayc
+ }
+
+ return true; //success
+ }
+ }
+ else
+ std::cerr << "Base_DB_Table_Data::record_new(): Empty field names or values." << std::endl;
+
+ return false; //Failed.
+}
+
bool Base_DB::insert_example_data(const Glib::ustring& table_name) const
{
//TODO_Performance: Avoid copying:
diff --git a/glom/base_db.h b/glom/base_db.h
index b6f3696..7461473 100644
--- a/glom/base_db.h
+++ b/glom/base_db.h
@@ -114,6 +114,17 @@ public:
bool change_columns(const Glib::ustring& table_name, const type_vec_const_fields& old_fields, type_vec_fields& fields, Gtk::Window* parent_window) const;
#endif //GLOM_ENABLE_CLIENT_ONLY
+ typedef std::pair< sharedptr<Field>, Gnome::Gda::Value> type_field_and_value;
+ typedef std::list<type_field_and_value> type_field_values;
+
+ /** Create a new record with all the specified field values.
+ * @param The table to which to add a new record.
+ * @param primary_key_value The new primary key value for the new record. Otherwise the primary key values must be in the the @a field_values parameter.
+ * @param field_values Values to use for fields, instead of entered data.
+ * @result true if the record was added to the database.
+ */
+ bool record_new(const Glib::ustring& table_name, const Gnome::Gda::Value& primary_key_value = Gnome::Gda::Value(), const type_field_values& field_values = type_field_values());
+
bool insert_example_data(const Glib::ustring& table_name) const;
typedef std::vector< sharedptr<LayoutItem_Field> > type_vecLayoutFields;
diff --git a/glom/base_db_table_data.cc b/glom/base_db_table_data.cc
index e75ff3a..f4a24b8 100644
--- a/glom/base_db_table_data.cc
+++ b/glom/base_db_table_data.cc
@@ -68,296 +68,28 @@ Gtk::TreeModel::iterator Base_DB_Table_Data::get_row_selected()
return Gtk::TreeModel::iterator();
}
-/** A predicate for use with std::find_if() to find a std::pair whose
- * first item is the same field.
- */
-class predicate_pair_has_field
+bool Base_DB_Table_Data::record_new_with_entered_data(const Gnome::Gda::Value& primary_key_value, const type_field_values& field_values)
{
-public:
- predicate_pair_has_field(const sharedptr<const Field>& field)
- {
- m_field = field;
- }
-
- template <class T_Second>
- bool operator() (const std::pair<sharedptr<Field>, T_Second>& element)
- {
- sharedptr<Field> field = element.first;
-
- if(!field && !m_field)
- return true;
-
- if(!field || !m_field)
- return false;
-
- //TODO: Check more than just the name:
- return (m_field->get_name() == field->get_name());
- }
-
-private:
- sharedptr<const Field> m_field;
-};
-
-
-bool Base_DB_Table_Data::record_new(const Glib::ustring& table_name, bool use_entered_data, const Gnome::Gda::Value& primary_key_value, const type_field_values& field_values)
-{
- //TODO: Remove these ugly optimizations:
- sharedptr<const Field> fieldPrimaryKey;
- if(table_name == m_table_name)
- {
- //An optimization:
- fieldPrimaryKey = get_field_primary_key();
- }
- else
- fieldPrimaryKey = get_field_primary_key_for_table(table_name);
-
-
- const Glib::ustring primary_key_name = fieldPrimaryKey->get_name();
-
- //Default to adding data for all fields that are on the layout,
- //if they contain data:
- type_vecLayoutFields fieldsToAdd;
- if(table_name == m_table_name)
- {
- //An optimization:
- //get_table_fields_to_show() needs knowledge of a layout,
- //which is only in a derived class,
- //but that class will have already set m_FieldsShown.
- //if(!m_FieldsShown.empty())
- // m_FieldsShown = get_table_fields_to_show(table_name);
-
- fieldsToAdd = m_FieldsShown;
- }
-
- //use_entered_data is not expected to work if table_name != m_table_name:
- //if(fieldsToAdd
- // fieldsToAdd = get_table_fields_to_show(table_name);
-
-
- //Get a list of all fields in the table,
- //not just the ones on the layout:
- type_vec_fields all_fields;
- if(table_name == m_table_name)
- {
- //An optimization:
- if(m_TableFields.empty())
- m_TableFields = get_fields_for_table(table_name);
-
- all_fields = m_TableFields;
- }
-
- if(all_fields.empty())
- all_fields = get_fields_for_table(table_name);
-
+ type_field_values field_values_plus_entered = field_values;
//Add values for all fields that default to something, not just the shown ones:
//For instance, we must always add the primary key, and fields with default/calculated/lookup values:
- for(type_vec_fields::const_iterator iter = all_fields.begin(); iter != all_fields.end(); ++iter)
+ const type_vecLayoutFields fieldsOnLayout = m_FieldsShown;
+ for(type_vecLayoutFields::const_iterator iter = fieldsOnLayout.begin(); iter != fieldsOnLayout.end(); ++iter)
{
+ //Check that we don't have a value for this field already:
+ //(This gives priority to specified fields values rather than entered field values.)
//TODO: Search for the non-related field with the name, not just the field with the name:
- type_vecLayoutFields::const_iterator iterFind = std::find_if(fieldsToAdd.begin(), fieldsToAdd.end(), predicate_FieldHasName<LayoutItem_Field>((*iter)->get_name()));
- if(iterFind == fieldsToAdd.end())
+ type_field_values::const_iterator iterFind = std::find_if(field_values_plus_entered.begin(), field_values_plus_entered.end(), predicate_FieldHasName<LayoutItem_Field>((*iter)->get_name()));
+ if(iterFind == field_values_plus_entered.end())
{
- sharedptr<LayoutItem_Field> layout_item = sharedptr<LayoutItem_Field>::create();
- layout_item->set_full_field_details(*iter);
-
- fieldsToAdd.push_back(layout_item);
+ field_values_plus_entered.push_back(*iter);
}
}
- Document* document = get_document();
- ConnectionPool* connection_pool = ConnectionPool::get_instance();
-
- //Calculate any necessary field values and enter them:
- for(type_vecLayoutFields::const_iterator iter = fieldsToAdd.begin(); iter != fieldsToAdd.end(); ++iter)
- {
- sharedptr<LayoutItem_Field> layout_item = *iter;
- if(!layout_item)
- continue;
-
- const sharedptr<const Field>& field = layout_item->get_full_field_details();
- if(!field)
- continue;
-
- //If the user did not enter something in this field:
- Gnome::Gda::Value value;
-
- //If the caller supplied a field value the use it,
- //otherwise try to get it from the UI:
- type_field_values::const_iterator iterFind =
- std::find_if(field_values.begin(), field_values.end(), predicate_pair_has_field(field));
- if(iterFind != field_values.end())
- value = iterFind->second;
- else
- value = get_entered_field_data(layout_item);
-
- if(Conversions::value_is_empty(value)) //This deals with empty strings too.
- {
- if(field) //TODO: Remove this check: we already check it above.
- {
- //If the default value should be calculated, then calculate it:
- if(field->get_has_calculation())
- {
- const Glib::ustring calculation = field->get_calculation();
- const type_map_fields field_values = get_record_field_values_for_calculation(table_name, fieldPrimaryKey, primary_key_value);
-
- //We need the connection when we run the script, so that the script may use it.
-#ifdef GLIBMM_EXCEPTIONS_ENABLED
- // TODO: Is this function supposed to throw an exception?
- sharedptr<SharedConnection> sharedconnection = connect_to_server(App_Glom::get_application());
-#else
- std::auto_ptr<ExceptionConnection> error;
- sharedptr<SharedConnection> sharedconnection = connect_to_server(App_Glom::get_application(), error);
- if(error.get() == NULL)
- {
- // Don't evaluate function on error
-#endif // GLIBMM_EXCEPTIONS_ENABLED
-
- const Gnome::Gda::Value value = glom_evaluate_python_function_implementation(field->get_glom_type(), calculation, field_values, document, table_name, sharedconnection->get_gda_connection());
- set_entered_field_data(layout_item, value);
-#ifndef GLIBMM_EXCEPTIONS_ENABLED
- }
-#endif // !GLIBMM_EXCEPTIONS_ENABLED
- }
-
- //Use default values (These are also specified in postgres as part of the field definition,
- //so we could theoretically just not specify it here.)
- //TODO_Performance: Add has_default_value()?
- if(Conversions::value_is_empty(value))
- {
- const Gnome::Gda::Value default_value = field->get_default_value();
- if(!Conversions::value_is_empty(default_value))
- {
- set_entered_field_data(layout_item, default_value);
- }
- }
- }
- }
- }
-
- //Get all entered field name/value pairs:
- Glib::ustring strNames;
- Glib::ustring strValues;
-
- //Avoid specifying the same field twice:
- typedef std::map<Glib::ustring, bool> type_map_added;
- type_map_added map_added;
- Glib::RefPtr<Gnome::Gda::Set> params = Gnome::Gda::Set::create();
-
- for(type_vecLayoutFields::const_iterator iter = fieldsToAdd.begin(); iter != fieldsToAdd.end(); ++iter)
- {
- sharedptr<LayoutItem_Field> layout_item = *iter;
- const Glib::ustring field_name = layout_item->get_name();
- if(!layout_item->get_has_relationship_name()) //TODO: Allow people to add a related record also by entering new data in a related field of the related record.
- {
- type_map_added::const_iterator iterFind = map_added.find(field_name);
- if(iterFind == map_added.end()) //If it was not added already
- {
- Gnome::Gda::Value value;
-
- const sharedptr<const Field>& field = layout_item->get_full_field_details();
- if(field)
- {
- //Use the specified (generated) primary key value, if there is one:
- if(primary_key_name == field_name && !Conversions::value_is_empty(primary_key_value))
- {
- value = primary_key_value;
- }
- else
- {
- if(use_entered_data)
- value = get_entered_field_data(layout_item);
- }
-
- //Handle the special creation fields:
- //TODO_performance: Avoid these string comparisons for each field:
- if(field_name == GLOM_STANDARD_DEFAULT_FIELD_CREATION_DATE)
- {
- value = Utils::get_current_date_utc_as_value();
- set_entered_field_data(layout_item, value);
- }
- else if(field_name == GLOM_STANDARD_DEFAULT_FIELD_CREATION_TIME)
- {
- value = Utils::get_current_time_utc_as_value();
- set_entered_field_data(layout_item, value);
- }
- else if(field_name == GLOM_STANDARD_DEFAULT_FIELD_CREATION_USER)
- {
- value = Gnome::Gda::Value(connection_pool->get_user());
- set_entered_field_data(layout_item, value);
- }
-
- /* //TODO: This would be too many small queries when adding one record.
- //Check whether the value meets uniqueness constraints:
- if(field->get_primary_key() || field->get_unique_key())
- {
- if(!get_field_value_is_unique(table_name, layout_item, value))
- {
- //Ignore this field value. TODO: Warn the user about it.
- }
- }
- */
- if(!value.is_null())
- {
- if(!strNames.empty())
- {
- strNames += ", ";
- strValues += ", ";
- }
-
- strNames += "\"" + field_name + "\"";
- strValues += field->get_gda_holder_string();
- const Glib::RefPtr<Gnome::Gda::Holder> holder = field->get_holder(value);
- params->add_holder(holder);
-
- map_added[field_name] = true;
- }
- }
- }
- }
- }
-
- //Put it all together to create the record with these field values:
- if(!strNames.empty() && !strValues.empty())
- {
- const Glib::ustring strQuery = "INSERT INTO \"" + table_name + "\" (" + strNames + ") VALUES (" + strValues + ")";
- const bool test = query_execute(strQuery, params);
- if(!test)
- std::cerr << "Box_Data::record_new(): INSERT failed." << std::endl;
- else
- {
- Gtk::TreeModel::iterator row = get_row_selected(); //Null and ignored for details views.
- set_primary_key_value(row, primary_key_value); //Needed by Box_Data_List::on_adddel_user_changed().
-
- //Update any lookups, related fields, or calculations:
- for(type_vecLayoutFields::const_iterator iter = fieldsToAdd.begin(); iter != fieldsToAdd.end(); ++iter)
- {
- sharedptr<const LayoutItem_Field> layout_item = *iter;
-
- //TODO_Performance: We just set this with set_entered_field_data() above. Maybe we could just remember it.
- const Gnome::Gda::Value field_value = get_entered_field_data(layout_item);
-
- LayoutFieldInRecord field_in_record(layout_item, table_name, fieldPrimaryKey, primary_key_value);
-
- //Get-and-set values for lookup fields, if this field triggers those relationships:
- do_lookups(field_in_record, row, field_value);
-
- //Update related fields, if this field is used in the relationship:
- refresh_related_fields(field_in_record, row, field_value);
-
- //TODO: Put the inserted row into result, somehow? murrayc
-
- return true; //success
- }
- }
- }
- else
- std::cerr << "Base_DB_Table_Data::record_new(): Empty field names or values." << std::endl;
-
- return false; //Failed.
+ return record_new(m_table_name, primary_key_value, field_values_plus_entered);
}
-
bool Base_DB_Table_Data::get_related_record_exists(const sharedptr<const Relationship>& relationship, const sharedptr<const Field>& key_field, const Gnome::Gda::Value& key_value)
{
BusyCursor cursor(App_Glom::get_application());
diff --git a/glom/base_db_table_data.h b/glom/base_db_table_data.h
index 1f47a5e..f394aa5 100644
--- a/glom/base_db_table_data.h
+++ b/glom/base_db_table_data.h
@@ -51,17 +51,12 @@ public:
protected:
- typedef std::pair< sharedptr<Field>, Gnome::Gda::Value> type_field_and_value;
- typedef std::list<type_field_and_value> type_field_values;
-
/** Create a new record with all the entered field values from the currently-active details/row.
- * @param The table to which to add a new record.
- * @param use_entered_data Whether the record should contain data already entered in the UI by the user, if table_name is m_table_name.
* @param primary_key_value The new primary key value for the new record. Otherwise the primary key value must be in the entered data or in the @a field_values parameter.
* @param field_values Values to use for fields, instead of entered data.
* @result true if the record was added to the database.
*/
- bool record_new(const Glib::ustring& table_name, bool use_entered_data = true, const Gnome::Gda::Value& primary_key_value = Gnome::Gda::Value(), const type_field_values& field_values = type_field_values());
+ bool record_new_with_entered_data(const Gnome::Gda::Value& primary_key_value = Gnome::Gda::Value(), const type_field_values& field_values = type_field_values());
Gnome::Gda::Value get_entered_field_data_field_only(const sharedptr<const Field>& field) const;
virtual Gnome::Gda::Value get_entered_field_data(const sharedptr<const LayoutItem_Field>& field) const;
diff --git a/glom/dialog_import_csv_progress.cc b/glom/dialog_import_csv_progress.cc
index 9e68870..cd2763c 100644
--- a/glom/dialog_import_csv_progress.cc
+++ b/glom/dialog_import_csv_progress.cc
@@ -201,7 +201,7 @@ bool Dialog_Import_CSV_Progress::on_idle_import()
else
{
std::cout << "Dialog_Import_CSV_Progress::on_idle_import(): Calling record_new() with primary_key_value=" << primary_key_value.to_string() << " ..." << std::endl;
- record_new(m_table_name, true /* use_entered_data */, primary_key_value);
+ record_new_with_entered_data(primary_key_value);
std::cout << "Dialog_Import_CSV_Progress::on_idle_import(): ... Finished calling record_new()" << std::endl;
}
@@ -251,7 +251,7 @@ Gnome::Gda::Value Dialog_Import_CSV_Progress::get_primary_key_value_selected() c
// in Base_DB_Table_Data.
void Dialog_Import_CSV_Progress::set_primary_key_value(const Gtk::TreeModel::iterator& /* row */, const Gnome::Gda::Value& /* value */)
{
- // This is actually called by Base_DB_Table_Data::record_new(), but we can safely ignore it.
+ // This is actually called by Base_DB_Table_Data::record_new_with_entered_data(), but we can safely ignore it.
//throw std::logic_error("Dialog_Import_CSV_Progress::set_primary_key_value() called");
}
diff --git a/glom/mode_data/box_data_details.cc b/glom/mode_data/box_data_details.cc
index 98d9c83..1b5cb70 100644
--- a/glom/mode_data/box_data_details.cc
+++ b/glom/mode_data/box_data_details.cc
@@ -419,7 +419,7 @@ void Box_Data_Details::on_button_new()
//Just make a new record, and show it:
Gnome::Gda::Value primary_key_value = get_next_auto_increment_value(m_table_name, m_field_primary_key->get_name()); //TODO: This should return a Gda::Value
- record_new(m_table_name, false /* use entered field data */, primary_key_value);
+ record_new(m_table_name, primary_key_value);
refresh_data_from_database_with_primary_key(primary_key_value);
}
else
@@ -849,7 +849,7 @@ void Box_Data_Details::on_flowtable_field_edited(const sharedptr<const LayoutIte
//Make a new record, and show it:
Gnome::Gda::Value primary_key_value = get_next_auto_increment_value(m_table_name, m_field_primary_key->get_name());
- record_new(m_table_name, true /* use entered field data */, primary_key_value);
+ record_new_with_entered_data(primary_key_value); //TODO: Check result.
refresh_data_from_database_with_primary_key(primary_key_value);
}
}
@@ -870,7 +870,7 @@ void Box_Data_Details::on_flowtable_field_edited(const sharedptr<const LayoutIte
//Create new record with this primary key,
//and all the other field values too.
//see comments after 'else':
- record_new(m_table_name, true /* use entered field data */);
+ record_new_with_entered_data();
}
}
else
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]