[glom: 9/9] Use Gnome::Gda::SqlBuilder
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glom: 9/9] Use Gnome::Gda::SqlBuilder
- Date: Fri, 26 Feb 2010 17:46:37 +0000 (UTC)
commit bc2565dc409769851841657c3c45c37d66c6a4ff
Merge: a6688e6 bc50237
Author: Murray Cumming <murrayc murrayc com>
Date: Fri Feb 26 18:46:00 2010 +0100
Use Gnome::Gda::SqlBuilder
* glom/base_db.[h|cc]: query_execute_select(), query_execute(),
auto_increment_insert_first_if_necessary(),
recalculate_next_auto_increment_value(),
get_next_auto_increment_value(), get_database_preferences(),
add_standard_table(), set_database_preferences(), insert_example_data(),
set_field_value_in_database():
Use Gnome::Gda::SqlBuilder to simplify query building and to make it
safer.
Most of this work was actually by Johannes Schmid for Openismus.
ChangeLog | 21 +++
glom/base_db.cc | 424 ++++++++++++++++++++++++++++++++++++++++---------------
glom/base_db.h | 9 +-
3 files changed, 337 insertions(+), 117 deletions(-)
---
diff --cc ChangeLog
index 62361aa,599233e..e95f1e6
--- a/ChangeLog
+++ b/ChangeLog
@@@ -1,732 -1,15 +1,746 @@@
-2009-12-04 Murray Cumming <murrayc murrayc com>
++2010-02-26 Murray Cumming <murrayc murrayc-desktop>
+
- Fix the build.
++ Use Gnome::Gda::SqlBuilder
+
- * glom/base_db.cc.[h|cc]: Use the newer simpler
- SqlBuilder::select_add_target() method.
++ * glom/base_db.[h|cc]: query_execute_select(), query_execute(),
++ auto_increment_insert_first_if_necessary(),
++ recalculate_next_auto_increment_value(),
++ get_next_auto_increment_value(), get_database_preferences(),
++ add_standard_table(), set_database_preferences(), insert_example_data(),
++ set_field_value_in_database():
++ Use Gnome::Gda::SqlBuilder to simplify query building and to make it
++ safer.
++ Most of this work was actually by Johannes Schmid for Openismus.
++
+2010-02-26 Murray Cumming <murrayc murrayc com>
+
+ Fixed the tests build.
+
+ * tests/test_python_execute_func.cc:
+ * tests/test_python_execute_func_date.cc: Updated for the
+ extra parameters for glom_evaluate_python_function_implementation().
+
+2010-02-25 Murray Cumming <murrayc murrayc com>
+
+ Python functions: Allow setting of values in the record via [].
+
+ * glom/python_embed/python_module/py_glom_module.cc: Specify a setitem(),
+ so python code can use [] syntax to set the record's field values as
+ well as getting them.
+ * glom/libglom/python_embed/py_glom_record.[h|cc]:
+ PyGlomRecord_SetFields(): Take and store the primary key details and value,
+ and use it in setitem() to UPDATE the value in the database.
+ * glom/python_embed/glom_python.[h|cc]:
+ glom_execute_python_function_implementation(),
+ glom_evaluate_python_function_implementation():
+ Take the primary key field and value.
+ * glom/base_db.cc:
+ * glom/base_db_table_data.cc:
+ * glom/mode_data/box_data.cc:
+ * glom/mode_design/fields/dialog_fieldcalculation.cc:
+ * glom/mode_design/layout/layout_item_dialogs/dialog_buttonscript.cc:
+ Adapted.
-2009-12-04 Murray Cumming <murrayc murrayc com>
+2010-02-22 Murray Cumming <murrayc murrayc com>
+
+ Avoid showing %20 in the window title.
+
+ * glom/libglom/document/bakery/document.cc: get_name():
+ Use Gio::FileInfo::get_display_name() instead of
+ Glib::filename_display_basename() or Glib::filename_display_name(), to avoid
+ showing %20 in the window title bar when there are spaces in the file name.
+ Noticed by Daniel Borgmann.
+
+1.13.5:
+
+2010-02-08 Peter Penz <ppenz openismus com>
+
+ libglom: Fix build issue for Maemo.
+
+ * glom/libglom/data_structure/glomconversions.cc: get_text_for_gda_value():
+ Add an ifdef for the disabled-exceptions build.
+
+
+2010-02-22 Murray Cumming <murrayc murrayc com>
+
+ Python functions: Fix regression since the switch to boost::python.
+
+ * glom/python_embed/python_module/py_glom_module.cc: PyRelatedRecord:
+ Fix a typo on the getitem() and len() declarations so we can really
+ get a related record.
+
+2010-02-22 Murray Cumming <murrayc murrayc com>
+
+ Python functions: Avoid a crash.
+
+ * glom/python_embed/glom_python.cc:
+ glom_evaluate_python_function_implementation(): When calling the
+ function object, catch exceptions instead of crashing.
+
+2010-02-12 Murray Cumming <murrayc murrayc com>
+
+ Glom Python: Minor code improvement.
+
+ * glom/python_embed/glom_python.cc: glom_evaluate_python_function_implemention():
+ Use the extra brackets trick to have boost::python::object and handle
+ on one line, so I have to care less about handle<>.
+
+2010-02-12 Murray Cumming <murrayc murrayc com>
+
+ Disable broken import tests.
+
+ * Makefile_tests.am: Comment out the use of the import tests during
+ make check. They hang most of the time, which is just stopping distcheck
+ from working. We need to fix these (and or the importing itself).
+ Then we can reenable them.
+
+2010-02-11 Murray Cumming <murrayc murrayc com>
+
+ libglom/python_embed/: get_item(): Pass object by const reference.
+
+ * glom/libglom/python_embed/py_glom_record.[h|cc]:
+ * glom/libglom/python_embed/py_glom_related.[h|cc]:
+ * glom/libglom/python_embed/py_glom_relatedrecord.[h|cc:
+ getitem(): Pass the object by const &.
+
+1.13.4:
+
+2010-02-11 Murray Cumming <murrayc murrayc com>
+
+ Rename boost::python m4 macro.
+
+ * configure.ac:
+ * macros/ax_boost_python.m4: Rename to ax_boost_python_macro.m4 and
+ rename the defined m4 macro, to avoid confusion with the cleaner (but
+ not working) original.
+
+2010-02-11 Murray Cumming <murrayc murrayc com>
+
+ Fix the build, due to file not added to git.
+
+ * glom/libglom/python_embed/pygdavalue_conversions.cc: Added missing
+ file to git.
+
+2010-02-11 Murray Cumming <murrayc murrayc com>
+
+ Fixes for the boost::python configure checks.
+
+ * configure.ac: AC_SUBST(PYTHON_CPPFLAGS) so our python checks can
+ use it.
+ * macros/ax_boost_python.m4: Use the previously-discovered python
+ CPPFLAGS and LIBS so our checks really work.
+
+2010-02-10 Murray Cumming <murrayc murrayc com>
+
+ Use boost::python instead of the Python C API, simplifying the code.
+
+ * configure.ac: Check for boost::python.
+ * Makefile.am:
+ * Makefile_glom.am: Use boost::python CFLAGS and LIBS.
+ * macros/ax_boost_python.m4: Added this macro from
+ http://www.nongnu.org/autoconf-archive/ax_boost_python.html
+ and hacked it to make it actually work.
+
+ * glom/python_embed/glom_python.cc: Use BOOST_PYTHON_MODULE() instead
+ of the obscure Python C API structs and fields that were here and in
+ the other .cc files.
+ * glom/main.cc:
+ * glom/libglom/python_embed/py_glom_record.[h|cc]
+ * glom/libglom/python_embed/py_glom_related.[h|cc]
+ * glom/libglom/python_embed/py_glom_relatedrecord.[h|cc]
+ * glom/python_embed/python_module/py_glom_module.[h|cc]:
+ * tests/test_python_execute_func.cc:
+ Use boost::python, for instance via boost::python::object, to
+ simplify memory management.
+
+ * Makefile_libglom.am:
+ * glom/libglom/python_embed/pygdavalue_conversions.[h|c]:
+ Change this to a .cc file, using C++, using boost::python.
+
+2010-02-08 Peter Penz <ppenz openismus com>
+
+ libglom: Fix build issue for Maemo.
+
+ * glom/libglom/data_structure/glomconversions.cc: get_text_for_gda_value():
+ Add an ifdef for the disabled-exceptions build.
+
+1.13.3:
+
+2010-02-03 Michael Hasselmann <michaelh openismus com>
+
+ Fixed a crash that got uncovered by the previous commit
+
+ * glom/libglom/utils.cc (build_sql_select_fields_to_get): Warn about layout
+ items that are null and skip them.
+
+2010-02-03 Michael Hasselmann <michaelh openismus com>
+
+ Added a guard clause when adding relationships from fields
+
+ * glom/libglom/utils.cc (add_to_relationships_list): If an invalid layout item
+ is passed then its relationship cannot be queried. Libglom users can also force
+ layout item fields that are null into this function, hence an additional guard
+ clause was added.
+
+2010-02-02 Murray Cumming <murrayc murrayc com>
+
+ Do not include pygtk.h
+
+ * glom/libglom/python_embed/py_glom_record.h:
+ * glom/libglom/python_embed/py_glom_relatedrecord.h:
+ * glom/python_embed/glom_python.cc: Include pygobject.h instead of
+ pygtk/pygtk.h, because we do not use anything from pygtk, or link to it.
+
+2010-01-31 Murray Cumming <murrayc murrayc com>
+
+ Command-line parsing: Added some checks.
+
+ * glom/main.cc: Test the command-line argument filepath for existence and
+ check that it's not a directory, so it fails before even showing UI.
+
+2010-01-31 Murray Cumming <murrayc murrayc com>
+
+ Relationships Overview: Avoid GTK+ warnings.
+
+ * glom/mode_design/relationships_overview/dialog_relationships_overview.cc:
+ Constructor: Call add_accel_group(), which fixes the warnings during
+ destruction mentioned in bug #607938.
+
+2010-01-31 Murray Cumming <murrayc murrayc com>
+
+ Relationships Overview: Maybe fix a hang/crash.
+
+ * glom/mode_design/relationships_overview/dialog_relationships_overview.[h|cc]:
+ Signal handlers: Take sigc::bind() RefPtr parameters by value instead of by
+ const &, to avoid having to use sigc::ref() or worry if it works.
+ Save sigc::connections in a list so we can disconnect signal handlers when
+ deleting items bound with sigc::bind(). Do this in the destructor too, which
+ seems to fix the valgrind errors in bug #594737, though not the
+ instance of invalid non-instantiatable type" warning.
+
+2010-01-27 Michael Hasselmann <michaelh openismus com>
+
+ Fixed the parser to perform stateless async file operations
+
+ * glom/import_csv/csv_parser.[h|cc]: The parser relied on a member variable for
+ its async giomm operations, which was able to cause interleaving state
+ changes to it, corrupting the object in the worst case. This commit uses the
+ source object as a slot parameter to avoid this state problem (working around
+ BGO bug #608269).
+
+ * tests/import/utils.[h|cc]: During import tests, break mainloop on file
+ read errors (e.g., no file at all).
+
+2010-01-27 Michael Hasselmann <michaelh openismus com>
+
+ Added a test for BGO bug #607938
+
+ * tests/import/data/albums.csv: Real-world example data used for the CSV
+ import.
+
+ * tests/import/utils.[h|cc]: Add the possibility to feed a filename into the
+ ImportTest directly.
+
+ * tests/import/test_parsing.cc: Test the CSV import of a whole file.
+
+2010-01-27 Michael Hasselmann <michaelh openismus com>
+
+ Added a g_return_if_fail check for invalid URLs
+
+ * glom/import_csv/csv_parser.cc: Do not start the async reading if the file
+ object is invalid.
+
+2010-01-27 Murray Cumming <murrayc murrayc com>
+
+ Use Gtk::ToolPalette from the latest gtkmm version, instead of
+ EggToolPalette (C) from libegg.
+
+2010-01-26 Murray Cumming <murrayc murrayc com>
+
+ libglom: Correct includes.
+
+ * glom/libglom/*.h: Use the full include libglom/ path for headers, to
+ avoid confusion and make life easier for other users of libglom.
+
+2010-01-25 Murray Cumming <murrayc murrayc com>
+
+ * glom/libglom/data_structure/numeric_format.h: Remove unnecessary
+ include of privileges.h.
+
+2010-01-25 Murray Cumming <murrayc murrayc com>
+
+ Allow new files to have quotes in their titles.
+
+ * glom/frame_glom.cc:
+ connection_request_password_and_choose_new_database_name():
+ Remove quotes (and other unusual characters) from the generated
+ database name, to avoid errors from the database backend.
+ Bug #607957 (Michael Hasselmann)
+
+2010-01-24 Michael Hasselmann <michael taschenorakel de>
+
+ Fixed out-ouf-bounds access during CSV imports
+
+ * glom/import_csv/dialog_import_csv.cc (get_field_for_column): Added boundary
+ check for direct field access. Fixes bug #607938.
+
+2010-01-24 Murray Cumming <murrayc murrayc com>
+
+ * ldtp/central-info.xml.example: Added an example central-info.xml, as
+ mentioned in the README.
+
+1.13.2:
+
+2010-01-24 Murray Cumming <murrayc murrayc com>
+
+ Details: Buttons: Use horizontal aligment from formatting.
+
+ * glom/mode_data/flowtablewithfields.cc: add_button_at_position():
+ Use a Gtk::HBox with either pack_start() or pack_end(), putting it in the
+ FlowTable with expand=true to have alignment in the button's space, if we
+ don't want the FlowTable's default (left) alignment.
+
+2010-01-24 Murray Cumming <murrayc murrayc com>
+
+ Details: Static Text items: Use horizontal alignment from formatting.
+
+ * glom/utility_widgets/labelglom.[h|cc]: Add a constructor that does not
+ take alignment values, like the Gtk::Label base class, so we can easily
+ use the default for vertical alignment.
+ * glom/mode_data/flowtablewithfields.cc: add_textobject_at_position():
+ Use expand=true when adding the widget to the FlowTable, so that labels can
+ have the full space in which to actually have alignment.
+ * glom/utility_widgets/layoutwidgetbase.cc: apply_formatting: Use appropriate
+ multi-line justification for labels, as a user would expect when setting
+ horizontal alignment.
+
+2010-01-23 Murray Cumming <murrayc murrayc com>
+
+ Details: Buttons: Use background color from formatting.
+
+ * glom/mode_data/flowtablewithfields.cc: add_button_at_position(): Call
+ apply_formatting on the button, not the label, so it has a chance to do the
+ right thing on the right widget.
+
+2010-01-23 Murray Cumming <murrayc murrayc com>
+
+ Details: Static Text items: Use background color from formatting.
+
+ * glom/utility_widgets/labelglom.cc: Do not call set_visible_window(false)
+ because we really need a visible child X window to be able to change the
+ background color.
+
+2010-01-23 Murray Cumming <murrayc murrayc com>
+
+ Details: Static Text items and Buttons: Use foreground color from formatting.
+
+ * glom/utility_widgets/layoutwidgetbase.cc: apply_formatting(): Use the
+ foreground color for labels (static text items and buttons).
+
+2010-01-22 Murray Cumming <murrayc murrayc com>
+
+ Details: Static Text items: Use formatting.
+
+ * glom/utility_widgets/labelglom.[h|cc]: Added get_label(), because this
+ really has a label as a child.
+ * glom/utility_widgets/layoutwidgetbase.cc: apply_formatting(): Use get_label()
+ to make formatting work on static text items too.
+
+2.13.1:
+
+2010-01-22 Murray Cumming <murrayc murrayc com>
+
+ Fixed compiler warnings.
+
+ * glom/libglom/data_structure/layout/layoutitem_field.cc:
+ get_formatting_used_horizontal_alignment():
+ * glom/print_layout/canvas_layout_item.cc: apply_formatting(): Fixed
+ compiler warnings.
+
+2010-01-22 Murray Cumming <murrayc murrayc com>
+
+ Make libglom-1.14 install in parallel with libglom-1.12.
+
+ * glom/libglom/glom-1.12.pc.in: Rename to glom-1.14.pc.in
+ * configure.ac: Change the libglom ABI version variable and specify the
+ changed .pc.in file.
+ * Makefile.am, Makefile_libglom.am: Adapt.
+ * glom/python_embed/python_module/py_glom_module.[h|cc]: Mention
+ 2.14 instead of 2.14.
+ * tests/test_load_python_library.cc: Adapt.
+
+ * glom/libglom/document/document.cc:
+ get_latest_known_document_format_version(): Increment.
+
+2010-01-22 Murray Cumming <murrayc murrayc com>
+
+ Really use formatting for multi-line fields.
+
+ * glom/utility_widgets/textviewglom.[h|cc]: Added get_textview().
+ * glom/utility_widgets/layoutwidgetbase.cc: apply_formatting():
+ Get the appropriate child for buttons and textviews, making this work
+ for textviews (multi line fields), but it still does not work for
+ labels (static text items) and buttons.
+
+2010-01-22 Murray Cumming <murrayc murrayc com>
+
+ Allow custom text formatting of Buttons as well as text items and fields.
+
+ * glom/libglom/data_structure/layout/layoutitem_button.[h|cc]:
+ Derive from LayoutItem_WithFormatting.
+ * glom/libglom/document/document.[h|cc]: Make loading/saving of
+ formatting generic so we get it for free whenever a new class
+ derives from LayoutItem_WithFormatting.
+ * glom/mode_data/flowtablewithfields.cc:
+ on_dnd_add_layout_item_button(): Try to apply the formatting to
+ the button's label, though it doesn't seem to work.
+
+2010-01-22 Murray Cumming <murrayc murrayc com>
+
+ Allow editing of formatting for static text items.
+
+ * glom/mode_design/layout/layout_item_dialogs/dialog_formatting.[h|cc]:
+ Added generic formatting (not choices, not default/custom) dialog
+ for static text items and maybe others.
+ * glom/mode_design/layout/layout_item_dialogs/box_formatting.[h|cc]:
+ set_formatting(): Add optional bool paramters to hide numeric formatting
+ and choices.
+ * glom/base_db.[h|cc]: Added offer_item_formatting() to use this dialog.
+ * glom/mode_design/layout/dialog_layout_details.cc(): Allow editing of
+ the formatting for static text items instead of just fields.
+
+ * glom/utility_widgets/db_adddel/db_adddel.cc:
+ construct_specified_columns_cellrenderer(): Apply the formatting to
+ any LayoutItem_WithFormatting, not just fields.
+ * glom/mode_data/flowtablewithfields.cc: add_textobject_at_position():
+ Try to apply the formatting to the label, but it doesn't seem to work.
- Fix the build.
+2010-01-22 Murray Cumming <murrayc murrayc com>
- * glom/base_db.[h|cc]: Correct the use of Gda::SqlBuilder for the latest API.
+ Add LayoutItem_WithFormatting as a Field/StaticText common base class.
+
+ * glom/libglom/data_structure/layout/layoutitem_withformatting.[h|cc]:
+ Added LayoutItem_WithFormatting.
+ * glom/libglom/data_structure/layout/layoutitem_text.[h|cc]:
+ * glom/libglom/data_structure/layout/layoutitem_field.[h|cc]:
+ Derive from Layout_WithFormatting, so we can use the base class
+ polymorphically, making it easier to support formatting for static text
+ items.
+ * glom/utility_widgets/layoutwidgetbase.[h|cc]: apply_formatting(),
+ * glom/print_layout/canvas_layout_item.[h|cc]: apply_formatting():
+ Make this generic for LayoutItem_WithFormatting.
+
+2010-01-22 Murray Cumming <murrayc murrayc com>
+
+ Show the alternative colors for negatives in fields with choices too.
+
+ * glom/utility_widgets/comboentryglom.cc: set_value():
+ * glom/utility_widgets/comboglom.cc: set_value(): Use the alternative
+ negative color feature here too.
+
+2010-01-21 Murray Cumming <murrayc murrayc com>
+
+ Field Formatting: Text Formatting: Add horizontal alignment option.
+
+ * glom/libglom/data_structure/layout/fieldformatting.[h|cc]:
+ Added get/set_horizontal_alignment().
+ * glom/libglom/data_structure/layout/layoutitem_field.[h|cc]:
+ Added get_formatting_used_horizontal_alignment() to interpret the
+ AUTO alignment depending on the fields details.
+ * glom/libglom/document/document.cc:
+ load_after_layout_item_formatting(), save_before_layout_item_formatting():
+ load/save the new setting.
+
+ * glom/glom_developer.glade: window_formatting: Added the alignment combo.
+ * glom/mode_design/layout/layout_item_dialogs/box_formatting.[h|cc]:
+ Show/Save the alignment.
+ * glom/utility_widgets/db_adddel/db_adddel.cc: apply_formatting():
+ * glom/utility_widgets/entryglom.cc: set_layout_item():
+ * glom/utility_widgets/comboentryglom.cc: set_layout_item():
+ Set xalign from get_formatting_used_horizontal_alignment().
+
+2010-01-16 Murray Cumming <murrayc murrayc com>
+
+ Field Formatting: Negative values color: Make this just a bool check box.
+
+ * glom/libglom/data_structure/numeric_format.[h|cc]: Use just a bool
+ to say if negative values should be shown in an alternative color.
+ Add static get_alternative_color_for_negatives() to get that color.
+ * glom/libglom/data_structure/layout/fieldformatting.cc:
+ get_text_format_color_foreground_to_use(): Updated the implementation.
+ * glom/libglom/document/document.cc:
+ load_after_layout_item_formatting(), save_before_layout_item_formatting():
+ Updated.
+
+ * glom/glom_developer.glade: window_formatting: Show only a checkbox, not
+ a color too, for the alternative color for negatives.
+ * glom/mode_design/layout/layout_item_dialogs/box_formatting.[h|cc]:
+ Updated.
+
+2010-01-15 Michael Hasselmann <michaelh openismus com>
+
+ Add forgotten header to libglom's Makefile
+
+ * Makefile_libglom.am: libglom_include_HEADERS forgot to mention utils.h
+ although it was mentioned in the *_la_SOURCES.
+
+
+2010-01-15 Michael Hasselmann <michaelh openismus com>
+
+ Updated the comment for NumericFormat's default precision
+
+ * glom/libglom/data_structure/numeric_format.h (get_default_precision): The
+ precision applies to the decimal places only, not the whole number. Comment
+ updated.
+
+2010-01-15 Murray Cumming <murrayc murrayc com>
+
+ Field Formatting: Allow an alternative color for negative values.
+
+ * glom/libglom/data_structure/numeric_format.[h|cc]:
+ Added m_foreground_color_for_negatives.
+ * glom/libglom/data_structure/layout/fieldformatting.[h|cc]:
+ Added get_text_format_color_foreground_to_use().
+ * glom/libglom/document/document.cc:
+ load_after_layout_item_formatting(), save_before_layout_item_formatting():
+ load/save the new setting.
+
+ * glom/glom_developer.glade: window_formatting: Added negatives color
+ and checkbox to the numeric formatting tab.
+ * glom/mode_design/layout/layout_item_dialogs/box_formatting.[h|cc]:
+ Show/Save the color.
+ * glom/utility_widgets/db_adddel/db_adddel.cc:
+ treeviewcolumn_on_cell_data()_
+ * glom/utility_widgets/entryglom.cc: set_value():
+ Use the color for negatives if appropriate.
+ * glom/print_layout/canvas_layout_item.cc: Add a TODO to use it here too.
+
+1.12.5 (stable):
+
+2010-01-20 Murray Cumming <murrayc murrayc com>
+
+ Fix a crash in previous commit.
+
+ * glom/utility_widgets/db_adddel/db_adddel.cc: get_fixed_cell_height():
+ Fixed a null-pointer crash when also checking LayoutItem_Text items,
+ though the UI doesn't actually allow the font to be specified for them
+ yet.
+
+2010-01-20 Murray Cumming <murrayc murrayc com>
+
+ List View: Don't chop off the bottom of text when using large fonts.
+
+ * glom/utility_widgets/db_adddel/db_adddel.cc: get_fixed_cell_height():
+ Use the font description from the FieldFormatting, to get a more
+ suitable max height for all columns.
+ remove_all_columns(): Set m_fixed_cell_height back to 0 so it
+ will be recalculated for the new columns.
+ Fixes bug #607023 (Michael Hasselmann)
+
+2010-01-14 Murray Cumming <murrayc murrayc com>
+
+ libglom: Some API documentation.
+
+ * glom/libglom/data_structure/layout/layoutitem_field.h:
+ * glom/libglom/data_structure/layout/usesrelationship.h:
+ Added doxygen comments at request of Michael Hasselmann.
+
+2010-01-14 Murray Cumming <murrayc murrayc com>
+
+ Rename get_stringstream_precision_default().
+
+ * glom/libglom/data_structure/glomconversions.[h|cc]:
+ get_stringstream_precision_default(): Rename this to the slighly-better
+ named (because it's not mentioning implementation)
+ NumericFormat::get_default_precision() in
+ * glom/libglom/data_structure/numeric_format.[h|cc]: and document it
+ vaguely.
+
+2010-01-14 Michael Hasselmann <michaelh openismus com>
+
+ Make the default precision used for stringstreams available for libglom users
+
+ * glom/libglom/data_structure/glomconversions.[h|cc]
+ (get_stringstream_precision_default): Wrap the constant used into a function
+ and export it in the headers. Users of libglom need it to show the same
+ precision for Glom's numeric type.
+
+2010-01-14 Murray Cumming <murrayc murrayc com>
+
+ Minor simplification.
+
+ * glom/libglom/data_structure/glomconversions.cc:
+ get_stringstream_precision_default(): Simplify this function, for
+ Michael to see.
+
+2010-01-14 Michael Hasselmann <michaelh openismus com>
+
+ Make the default precision used for stringstreams available for libglom users
+
+ * glom/libglom/data_structure/glomconversions.[h|cc]
+ (get_stringstream_precision_default): Wrap the constant used into a function
+ and export it in the headers. Users of libglom need it to show the same
+ precision for Glom's numeric type.
+
+
+2010-01-12 Murray Cumming <murrayc murrayc com>
+
+ Music Collection Example: Changed a layout.
+
+ * examples/example_music_collection.glom: Albums: List View:
+ Add some related records to show a problem in Qlom.
+
+2010-01-08 Murray Cumming <murrayc murrayc com>
+
+ Correct use of locales when creating text representations.
+
+ * glom/main.cc: Set std::locale::global() to the user's current locale,
+ forcing us to imbue streams to whatever we actually want.
+ * glom/libglom/connectionpool_backends/postgres_self.cc: startup():
+ Do not use Utils::string_from_decimal() for the port number, because it
+ is meant to use the user's locale, but we need it in the C locale.
+ * glom/libglom/data_structure/field.cc: to_file_format(): Use
+ std::locale::classic() when we want the C locale, not std::locale(),
+ which means the user's locale, which was previously the C one by chance.
+ * glom/libglom/utils.cc: string_from_decimal(): Imbue the stream
+ as wanted.
+
+2010-01-07 Michael Hasselmann <michaelh openismus com>
+
+ Fix potential encoding error for currency symbols
+
+ * glom/libglom/data_structure/glomconversions.cc (get_text_for_gda_value):
+ Glom's numeric type can be prefixed with a currency symbol. If the symbol
+ cannot be represented in the user's locale it would hide all data for the
+ column. This is fixed by using a fallback conversion for the symbol.
+ Fixes bug #606349.
+
+2010-01-07 Armin Burgmeier <armin arbur net>
+
+ * win32/build-installer:
+ * win32/glom.iss.in: Install glom_1_12.pyd instead of glom.pyd. Bug
+ #605593.
+
+1.12.4:
+
+2009-12-30 Murray Cumming <murrayc murrayc com>
+
+ Dnd layout: Avoid a crash when dragging to empty space.
+
+ * glom/utility_widgets/flowtable_dnd.cc: on_drag_data_received():
+ Avoid dereferencing a null group.
+ Bug #599232
+
+2009-12-30 Murray Cumming <murrayc murrayc com>
+
+ Dnd layout: Avoid a crash.
+
+ * glom/utility_widgets/flowtable_dnd.cc: on_drag_data_received():
+ Use a dynamic_cast<> to avoid memory corruption with the MI class.
+ Bug #599232
+
+2009-12-16 Armin Burgmeier <armin arbur net>
+
+ * win32/build-installer:
+ * win32/glom.iss.in: Add missing libpangoft2-1.0-0.dll. Bug #599966.
+
+2009-12-14 Murray Cumming <murrayc murrayc com>
+
+ * glom.desktop.in.in: Remove the Application category because
+ krazy2 says it is deprecated.
+
+2009-12-10 Murray Cumming <murrayc murrayc com>
+
+ FlowTableDnd: Some refactoring.
+
+ * glom/utility_widgets/flowtable_dnd.[h|cc],
+ * glom/mode_data/flowtable_withfields.[h|cc]: Make FlowTableDnd less
+ aware of LayoutItems, though it is still not yet generic enough.
+ * glom/utility_widgets/test_flowtable_dnd.cc:
+ * glom/Makefile_tests.am: Added test_flowtable_dnd.
+
+2009-12-10 Murray Cumming <murrayc murrayc com>
+
+ * examples/example_film_manager.glom: Added silly example data,
+ fixing bug #600859 (Michael Hasselmann)
+
+2009-12-10 Murray Cumming <murrayc murrayc com>
+
+ Tests: Validate all examples against the DTD, and correct the DTD.
+
+ * tests/dtd/test_example_sqlite: Renamed to test_file_validation.sh.
+ * glom/Makefile_tests.am: Adapted.
+ * glom/libglom/document/document.cc: save_before(): Correct the saving
+ of group privileges so they are really inside the group nodes. Avoid
+ saving unnamed groups, as seen in the example files.
+ * glom/glom_document.dtd: Several corrections to fix the validation of
+ the example files, though I don't like that DTDs don't seem to give
+ us any way to say that the sequence of child elements is irrelevant.
+ I don't like enforcing the sequence.
+
+2009-12-10 Murray Cumming <murrayc murrayc com>
+
+ Fix distcheck.
+
+ * Makefile.am:
+ * Makefile_tests.am: Fix the distcheck by disting the DTD validation
+ test script and the .glom file that it uses.
+ * glom/libglom/init.cc: Redefine Python's PyDateTime_IMPORT macro,
+ to avoid a compiler warning. See http://bugs.python.org/issue7463
+ * glom/main.cc: Avoid including Python's datetime.h, to avoid the same
+ compiler warning.
+
+2009-12-09 Murray Cumming <murrayc murrayc-desktop>
+
+ Tests: Complete the test_python_execute_func_date test.
+
+ * glom/libglom/python_embed/pygdavalue_conversions.c
+ (glom_pygda_value_from_pyobject): Use g_date_new_dmy() so the GDate
+ is really completely initialized, avoiding errors about invalid dates.
+ * tests/test_python_execute_func_date.cc: Check the return type and
+ value, by comparing the python result with the current date.
+ Bug is now really fixed #603686. (Andrew Ruthven)
+
+2009-12-09 Murray Cumming <murrayc murrayc com>
+
+ Fix the crash when calling python functions that return dates.
+
+ * glom/libglom/python_embed/pygdavalue_conversions.c
+ (glom_pygda_value_from_pyobject): Call the macro PyDateTime_IMPORT here,
+ though it was already called in libglom_init(). I don't know why this
+ fixes the crash, but it does. Bug #603686. (Andrew Ruthven)
+
+2009-12-08 Murray Cumming <murrayc murrayc com>
+
+ Tests: Added glom_evaluate_python_function_implementation() tests.
+
+ * Makefile_tests.am:
+ * tests/test_python_execute_func.cc:
+ * tests/test_python_execute_func_date.cc: Added two unit tests for
+ Glom::glom_evaluate_python_function_implementation(). The date one
+ currently fails, as in bug #603686. (Andrew Ruthven)
+
+2009-12-07 Murray Cumming <murrayc murrayc com>
+
+ Python: Trying to stop the PyDateTime_Check() crash.
+
+ * glom/libglom/init.cc: libglom_init(): Call the PyDateTime_IMPORT
+ macro, which is needed to stop PyDateTime_Check() and PyDate_Check()
+ from crashing, at least in my simple test case. It still crashes in
+ Glom though.
+ * glom/main.cc: Do not initialize Python here because Glom::init()
+ already did it, though doing it twice does not seem to be a problem.
+
+2009-12-04 Murray Cumming <murrayc murrayc-desktop>
+
+ Rename some functions to avoid fear of linking to the wrong one.
+
+ * glom/libglom/python_embed/pygdavalue_conversions.[h|cc]:
+ pygda_value_from_pyobject(), pygda_value_as_pyobject(): Add a glom_
+ prefix so we know we are not using the copy in pygda.
+ * glom/python_embed/glom_python.cc:
+ * glom/libglom/python_embed/py_glom_record.cc:
+ * glom/libglom/python_embed/py_glom_relatedrecord.cc: Adapted.
2009-12-04 Murray Cumming <murrayc murrayc com>
@@@ -937,9 -220,16 +951,16 @@@
2009-10-27 Murray Cumming <murrayc murrayc com>
- * glom/utility_widgets/db_adddel/db_adddel.cc: treeview_append_column():
+ * glom/utility_widgets/db_adddel/db_adddel.cc: treeview_append_column():
Don't try to put -1 in a guint for the column width.
+ 2009-10-25 Murray Cumming <murrayc murrayc com>
+
+ BaseDb::query_execute*(): Const corrections.
-
- * glom/base_db.[h|cc]: query_execute(), query_execute_select():
++
++ * glom/base_db.[h|cc]: query_execute(), query_execute_select():
+ Const corrections and indentation corrections.
+
2009-10-21 Armin Burgmeier <armin arbur net>
* Makefile_libglom.am: Link against winsock on Windows.
diff --cc glom/base_db.cc
index eafcaf2,2d07057..6f5718d
--- a/glom/base_db.cc
+++ b/glom/base_db.cc
@@@ -267,6 -266,107 +267,107 @@@ Glib::RefPtr<Gnome::Gda::DataModel> Bas
}
//static:
+ Glib::RefPtr<Gnome::Gda::DataModel> Base_DB::query_execute_select(const Glib::RefPtr<const Gnome::Gda::SqlBuilder>& builder,
+ const Glib::RefPtr<const Gnome::Gda::Set>& params)
+ {
+ Glib::RefPtr<Gnome::Gda::DataModel> result;
+
+ //TODO: BusyCursor busy_cursor(get_app_window());
+
+ #ifdef GLIBMM_EXCEPTIONS_ENABLED
+ sharedptr<SharedConnection> sharedconnection = connect_to_server();
+ #else
+ std::auto_ptr<ExceptionConnection> error;
+ sharedptr<SharedConnection> sharedconnection = connect_to_server(0, error);
+ if(error.get())
+ {
+ g_warning("Base_DB::query_execute_select() failed (query was: %s): %s", strQuery.c_str(), error->what());
- // TODO: Rethrow?
++ // TODO: Rethrow?
+ }
+ #endif
+ if(!sharedconnection)
+ {
+ std::cerr << "Base_DB::query_execute_select(): No connection yet." << std::endl;
+ return result;
+ }
+
+ Glib::RefPtr<Gnome::Gda::Connection> gda_connection = sharedconnection->get_gda_connection();
+ Glib::RefPtr<Gnome::Gda::Statement> stmt;
+ #ifdef GLIBMM_EXCEPTIONS_ENABLED
+ try
+ {
+ stmt = builder->get_statement();
+ }
+ catch(const Gnome::Gda::SqlBuilderError& ex)
+ {
+ std::cout << "debug: Base_DB::query_execute_select(): SqlParserError: exception from parse_string(): " << ex.what() << std::endl;
+ }
+ #else
+ std::auto_ptr<Glib::Error> ex;
+ stmt = builder->get_statement(ex);
+ if(error.get())
+ std::cout << "debug: Base_DB::query_execute_select(): SqlParserError: exception from parse_string(): " << error->what() << std::endl;
+ #endif //GLIBMM_EXCEPTIONS_ENABLED
+
+
+ //Debug output:
+ const App_Glom* app = App_Glom::get_application();
+ if(stmt && app && app->get_show_sql_debug())
+ {
+ #ifdef GLIBMM_EXCEPTIONS_ENABLED
+ try
+ {
+ const Glib::ustring full_query = stmt->to_sql(params);
+ std::cout << "Debug: Base_DB::query_execute_select(): " << full_query << std::endl;
+ }
+ catch(const Glib::Exception& ex)
+ {
+ std::cout << "Debug: query string could not be converted to std::cout: " << ex.what() << std::endl;
+ }
+ #else
+ const Glib::ustring full_query = stmt->to_sql(params, ex);
+ std::cout << "Debug: Base_DB::query_execute_select(): " << full_query << std::endl;
+ if (ex.get())
+ std::cout << "Debug: query string could not be converted to std::cout: " << ex->what() << std::endl;
-
++
+ #endif
+ }
+
-
++
+ #ifdef GLIBMM_EXCEPTIONS_ENABLED
+ try
+ {
+ result = gda_connection->statement_execute_select(stmt, params);
+ }
+ catch(const Gnome::Gda::ConnectionError& ex)
+ {
+ std::cout << "debug: Base_DB::query_execute_select(): ConnectionError: exception from statement_execute_select(): " << ex.what() << std::endl;
+ }
+ catch(const Gnome::Gda::ServerProviderError& ex)
+ {
+ std::cout << "debug: Base_DB::query_execute_select(): ServerProviderError: exception from statement_execute_select(): code=" << ex.code() << "message=" << ex.what() << std::endl;
+ }
+ catch(const Glib::Error& ex)
+ {
+ std::cout << "debug: Base_DB::query_execute_select(): Error: exception from statement_execute_select(): " << ex.what() << std::endl;
+ }
+
+ #else
+ result = gda_connection->statement_execute_select(stmt, params, ex);
+ if(ex.get())
+ std::cout << "debug: Base_DB::query_execute_select(): Glib::Error from statement_execute_select(): " << ex->what() << std::endl;
+ #endif //GLIBMM_EXCEPTIONS_ENABLED
+
+ if(!result)
+ {
+ std::cerr << "Glom Base_DB::query_execute_select(): Error while executing SQL" << std::endl << std::endl;
+ handle_error();
+ }
+
+ return result;
+ }
+
+ //static:
bool Base_DB::query_execute(const Glib::ustring& strQuery,
const Glib::RefPtr<Gnome::Gda::Set>& params)
{
@@@ -363,6 -463,98 +464,98 @@@
return (exec_retval >= 0);
}
+ //static:
+ bool Base_DB::query_execute(const Glib::RefPtr<const Gnome::Gda::SqlBuilder>& builder,
+ const Glib::RefPtr<const Gnome::Gda::Set>& params)
+ {
+ #ifdef GLIBMM_EXCEPTIONS_ENABLED
+ sharedptr<SharedConnection> sharedconnection = connect_to_server();
+ #else
+ std::auto_ptr<ExceptionConnection> error;
+ sharedptr<SharedConnection> sharedconnection = connect_to_server(0, error);
+ if(error.get())
+ {
+ g_warning("Base_DB::query_execute() failed (query was: %s): %s", strQuery.c_str(), error->what());
- // TODO: Rethrow?
++ // TODO: Rethrow?
+ }
+ #endif
+ if(!sharedconnection)
+ {
+ std::cerr << "Base_DB::query_execute(): No connection yet." << std::endl;
+ return false;
+ }
-
++
+ Glib::RefPtr<Gnome::Gda::Connection> gda_connection = sharedconnection->get_gda_connection();
+ Glib::RefPtr<Gnome::Gda::Statement> stmt;
+ #ifdef GLIBMM_EXCEPTIONS_ENABLED
+ try
+ {
+ stmt = builder->get_statement();
+ }
+ catch(const Gnome::Gda::SqlBuilderError& ex)
+ {
+ std::cout << "debug: Base_DB::query_execute_select(): SqlParserError: exception from parse_string(): " << ex.what() << std::endl;
+ }
+ #else
+ std::auto_ptr<Glib::Error> ex;
+ stmt = builder->get_statement(ex);
+ if(error.get())
+ std::cout << "debug: Base_DB::query_execute_select(): SqlParserError: exception from parse_string(): " << error->what() << std::endl;
+ #endif //GLIBMM_EXCEPTIONS_ENABLED
+
+
+ //Debug output:
+ const App_Glom* app = App_Glom::get_application();
+ if(stmt && app && app->get_show_sql_debug())
+ {
+ #ifdef GLIBMM_EXCEPTIONS_ENABLED
+ try
+ {
- //TODO: full_query still seems to contain ## parameter names,
- //though it works for our SELECT queries in query_execute_select():
++ //TODO: full_query still seems to contain ## parameter names,
++ //though it works for our SELECT queries in query_execute_select():
+ const Glib::ustring full_query = stmt->to_sql(params);
+ std::cerr << "Debug: Base_DB::query_execute(): " << full_query << std::endl;
+ }
+ catch(const Glib::Exception& ex)
+ {
+ std::cerr << "Debug: query string could not be converted to std::cout: " << ex.what() << std::endl;
+ }
+ #else
+ const Glib::ustring full_query = stmt->to_sql(params, sql_error);
+ std::cerr << "Debug: Base_DB::query_execute(): " << full_query << std::endl;
+ if (sql_error.get())
+ std::cerr << "Debug: query string could not be converted to std::cout: " << sql_error->what() << std::endl;
+ #endif
+ }
+
+
+ int exec_retval = -1;
+ #ifdef GLIBMM_EXCEPTIONS_ENABLED
+ try
+ {
+ exec_retval = gda_connection->statement_execute_non_select(stmt, params);
+ }
+ catch(const Glib::Error& error)
+ {
+ std::cerr << "BaseDB::query_execute: ConnectionError: " << error.what() << std::endl;
+ const Glib::ustring full_query = stmt->to_sql(params);
+ std::cerr << " full_query: " << full_query << std::endl;
+ return false;
+ }
+ #else
+ std::auto_ptr<Glib::Error> exec_error;
+ exec_retval = gda_connection->statement_execute_non_select(stmt, params, exec_error);
+ if(exec_error.get())
+ {
+ std::cerr << "BaseDB::query_execute: ConnectionError: " << exec_error->what() << std::endl;
+ const Glib::ustring full_query = stmt->to_sql(params, exec_error);
+ std::cerr << " full_query: " << full_query << std::endl;
+ return false;
+ }
+ #endif
+ return (exec_retval >= 0);
+ }
+
void Base_DB::load_from_document()
{
if(get_document())
@@@ -892,15 -1084,21 +1085,21 @@@ Gnome::Gda::Value Base_DB::auto_increme
//This should not happen:
std::cerr << "Glom: Base_DB::auto_increment_insert_first_if_necessary(): The current user may not edit the autoincrements table. Any user who has create rights for a table should have edit rights to the autoincrements table." << std::endl;
}
- Glib::RefPtr<Gnome::Gda::Set> params = Gnome::Gda::Set::create();
- params->add_holder("table_name", table_name);
- params->add_holder("field_name", field_name);
-
- Glib::RefPtr<Gnome::Gda::SqlBuilder> builder =
+
- const Glib::ustring sql_query = "SELECT \"" GLOM_STANDARD_TABLE_AUTOINCREMENTS_TABLE_NAME "\".\"next_value\" FROM \"" GLOM_STANDARD_TABLE_AUTOINCREMENTS_TABLE_NAME "\""
- " WHERE \"" GLOM_STANDARD_TABLE_AUTOINCREMENTS_FIELD_TABLE_NAME "\" = ##table_name::gchararray AND "
- "\"" GLOM_STANDARD_TABLE_AUTOINCREMENTS_FIELD_FIELD_NAME "\" = ##field_name::gchararray";
-
- Glib::RefPtr<Gnome::Gda::DataModel> datamodel = query_execute_select(sql_query, params);
++ Glib::RefPtr<Gnome::Gda::SqlBuilder> builder =
+ Gnome::Gda::SqlBuilder::create(Gnome::Gda::SQL_STATEMENT_SELECT);
+ builder->select_add_field("next_value", GLOM_STANDARD_TABLE_AUTOINCREMENTS_TABLE_NAME);
+ builder->select_add_target(GLOM_STANDARD_TABLE_AUTOINCREMENTS_TABLE_NAME);
+ builder->set_where(
+ builder->add_cond(Gnome::Gda::SQL_OPERATOR_TYPE_AND,
+ builder->add_cond(Gnome::Gda::SQL_OPERATOR_TYPE_EQ,
+ builder->add_id(GLOM_STANDARD_TABLE_AUTOINCREMENTS_FIELD_TABLE_NAME),
+ builder->add_expr(table_name)),
+ builder->add_cond(Gnome::Gda::SQL_OPERATOR_TYPE_EQ,
+ builder->add_id(GLOM_STANDARD_TABLE_AUTOINCREMENTS_FIELD_FIELD_NAME),
+ builder->add_expr(field_name))));
-
++
+ const Glib::RefPtr<const Gnome::Gda::DataModel> datamodel = query_execute_select(builder);
if(!datamodel || (datamodel->get_n_rows() == 0))
{
//Start with zero:
@@@ -944,8 -1145,13 +1146,13 @@@ void Base_DB::recalculate_next_auto_inc
auto_increment_insert_first_if_necessary(table_name, field_name);
//Get the max key value in the database:
- const Glib::ustring sql_query = "SELECT MAX(\"" + table_name + "\".\"" + field_name + "\") FROM \"" + table_name + "\"";
- Glib::RefPtr<Gnome::Gda::DataModel> datamodel = query_execute_select(sql_query);
+ Glib::RefPtr<Gnome::Gda::SqlBuilder> builder = Gnome::Gda::SqlBuilder::create(Gnome::Gda::SQL_STATEMENT_SELECT);
+ std::list<guint> args;
+ args.push_back(builder->add_id(table_name + "." + field_name));
+ builder->add_field_id(builder->add_function("MAX", args));
+ builder->select_add_target(table_name);
-
++
+ Glib::RefPtr<Gnome::Gda::DataModel> datamodel = query_execute_select(builder);
if(datamodel && datamodel->get_n_rows() && datamodel->get_n_columns())
{
//Increment it:
@@@ -960,12 -1166,20 +1167,20 @@@
//Set it in the glom system table:
const Gnome::Gda::Value next_value = Conversions::parse_value(num_max);
- const Glib::ustring sql_query = "UPDATE \"" GLOM_STANDARD_TABLE_AUTOINCREMENTS_TABLE_NAME "\" SET "
- "\"" GLOM_STANDARD_TABLE_AUTOINCREMENTS_FIELD_NEXT_VALUE "\" = " + next_value.to_string() + //TODO: Don't use to_string().
- " WHERE \"" GLOM_STANDARD_TABLE_AUTOINCREMENTS_FIELD_TABLE_NAME "\" = '" + table_name + "' AND "
- "\"" GLOM_STANDARD_TABLE_AUTOINCREMENTS_FIELD_FIELD_NAME "\" = '" + field_name + "'";
- const bool test = query_execute(sql_query);
+ builder.reset();
+ builder = Gnome::Gda::SqlBuilder::create(Gnome::Gda::SQL_STATEMENT_UPDATE);
+ builder->set_table(GLOM_STANDARD_TABLE_AUTOINCREMENTS_TABLE_NAME);
+ builder->add_field_value_as_value(GLOM_STANDARD_TABLE_AUTOINCREMENTS_FIELD_NEXT_VALUE, next_value);
+ builder->set_where(builder->add_cond(Gnome::Gda::SQL_OPERATOR_TYPE_AND,
+ builder->add_cond(Gnome::Gda::SQL_OPERATOR_TYPE_EQ,
+ builder->add_id(GLOM_STANDARD_TABLE_AUTOINCREMENTS_FIELD_TABLE_NAME),
+ builder->add_expr(table_name)),
+ builder->add_cond(Gnome::Gda::SQL_OPERATOR_TYPE_EQ,
+ builder->add_id(GLOM_STANDARD_TABLE_AUTOINCREMENTS_FIELD_FIELD_NAME),
+ builder->add_expr(field_name))));
-
++
+ const bool test = query_execute(builder);
if(!test)
std::cerr << "Base_DB::recalculate_next_auto_increment_value(): UPDATE failed." << std::endl;
}
@@@ -982,16 -1196,18 +1197,18 @@@ Gnome::Gda::Value Base_DB::get_next_aut
//Increment the next_value:
++num_result;
const Gnome::Gda::Value next_value = Conversions::parse_value(num_result);
- Glib::RefPtr<Gnome::Gda::Set> params = Gnome::Gda::Set::create();
- params->add_holder("table_name", table_name);
- params->add_holder("field_name", field_name);
- params->add_holder("next_value", next_value);
- const Glib::ustring sql_query = "UPDATE \"" GLOM_STANDARD_TABLE_AUTOINCREMENTS_TABLE_NAME "\" SET "
- "\"" GLOM_STANDARD_TABLE_AUTOINCREMENTS_FIELD_NEXT_VALUE "\" = ##next_value::gchararray"
- " WHERE \"" GLOM_STANDARD_TABLE_AUTOINCREMENTS_FIELD_TABLE_NAME "\" = ##table_name::gchararray AND "
- "\"" GLOM_STANDARD_TABLE_AUTOINCREMENTS_FIELD_FIELD_NAME "\" = ##field_name::gchararray";
-
- const bool test = query_execute(sql_query, params);
+
+ Glib::RefPtr<Gnome::Gda::SqlBuilder> builder = Gnome::Gda::SqlBuilder::create(Gnome::Gda::SQL_STATEMENT_UPDATE);
+ builder->set_table(GLOM_STANDARD_TABLE_AUTOINCREMENTS_TABLE_NAME);
+ builder->add_field_value_as_value(GLOM_STANDARD_TABLE_AUTOINCREMENTS_FIELD_NEXT_VALUE, next_value);
+ builder->set_where(builder->add_cond(Gnome::Gda::SQL_OPERATOR_TYPE_AND,
+ builder->add_cond(Gnome::Gda::SQL_OPERATOR_TYPE_EQ,
+ builder->add_id(GLOM_STANDARD_TABLE_AUTOINCREMENTS_FIELD_TABLE_NAME),
+ builder->add_expr(table_name)),
+ builder->add_cond(Gnome::Gda::SQL_OPERATOR_TYPE_EQ,
+ builder->add_id(GLOM_STANDARD_TABLE_AUTOINCREMENTS_FIELD_FIELD_NAME),
- builder->add_expr(field_name))));
++ builder->add_expr(field_name))));
+ const bool test = query_execute(builder);
if(!test)
std::cerr << "Base_DB::get_next_auto_increment_value(): Increment failed." << std::endl;
@@@ -1012,18 -1228,24 +1229,24 @@@ SystemPrefs Base_DB::get_database_prefe
const bool optional_org_logo = get_field_exists_in_database(GLOM_STANDARD_TABLE_PREFS_TABLE_NAME, GLOM_STANDARD_TABLE_PREFS_FIELD_ORG_LOGO);
- const Glib::ustring sql_query = "SELECT "
- "\"" GLOM_STANDARD_TABLE_PREFS_TABLE_NAME "\".\"" GLOM_STANDARD_TABLE_PREFS_FIELD_NAME "\", "
- "\"" GLOM_STANDARD_TABLE_PREFS_TABLE_NAME "\".\"" GLOM_STANDARD_TABLE_PREFS_FIELD_ORG_NAME "\", "
- "\"" GLOM_STANDARD_TABLE_PREFS_TABLE_NAME "\".\"" GLOM_STANDARD_TABLE_PREFS_FIELD_ORG_ADDRESS_STREET "\", "
- "\"" GLOM_STANDARD_TABLE_PREFS_TABLE_NAME "\".\"" GLOM_STANDARD_TABLE_PREFS_FIELD_ORG_ADDRESS_STREET2 "\", "
- "\"" GLOM_STANDARD_TABLE_PREFS_TABLE_NAME "\".\"" GLOM_STANDARD_TABLE_PREFS_FIELD_ORG_ADDRESS_TOWN "\", "
- "\"" GLOM_STANDARD_TABLE_PREFS_TABLE_NAME "\".\"" GLOM_STANDARD_TABLE_PREFS_FIELD_ORG_ADDRESS_COUNTY "\", "
- "\"" GLOM_STANDARD_TABLE_PREFS_TABLE_NAME "\".\"" GLOM_STANDARD_TABLE_PREFS_FIELD_ORG_ADDRESS_COUNTRY "\", "
- "\"" GLOM_STANDARD_TABLE_PREFS_TABLE_NAME "\".\"" GLOM_STANDARD_TABLE_PREFS_FIELD_ORG_ADDRESS_POSTCODE "\""
- + Glib::ustring(optional_org_logo ? ", \"" GLOM_STANDARD_TABLE_PREFS_TABLE_NAME "\".\"" GLOM_STANDARD_TABLE_PREFS_FIELD_ORG_LOGO "\"" : "") +
- " FROM \"" GLOM_STANDARD_TABLE_PREFS_TABLE_NAME "\"";
- Glib::RefPtr<Gnome::Gda::SqlBuilder> builder =
++ Glib::RefPtr<Gnome::Gda::SqlBuilder> builder =
+ Gnome::Gda::SqlBuilder::create(Gnome::Gda::SQL_STATEMENT_SELECT);
+ builder->select_add_field(GLOM_STANDARD_TABLE_PREFS_FIELD_NAME, GLOM_STANDARD_TABLE_PREFS_TABLE_NAME);
+ builder->select_add_field(GLOM_STANDARD_TABLE_PREFS_FIELD_ORG_NAME, GLOM_STANDARD_TABLE_PREFS_TABLE_NAME);
+ builder->select_add_field(GLOM_STANDARD_TABLE_PREFS_FIELD_ORG_ADDRESS_STREET, GLOM_STANDARD_TABLE_PREFS_TABLE_NAME);
+ builder->select_add_field(GLOM_STANDARD_TABLE_PREFS_FIELD_ORG_ADDRESS_STREET2, GLOM_STANDARD_TABLE_PREFS_TABLE_NAME);
+ builder->select_add_field(GLOM_STANDARD_TABLE_PREFS_FIELD_ORG_ADDRESS_TOWN, GLOM_STANDARD_TABLE_PREFS_TABLE_NAME);
+ builder->select_add_field(GLOM_STANDARD_TABLE_PREFS_FIELD_ORG_ADDRESS_COUNTY, GLOM_STANDARD_TABLE_PREFS_TABLE_NAME);
+ builder->select_add_field(GLOM_STANDARD_TABLE_PREFS_FIELD_ORG_ADDRESS_COUNTRY, GLOM_STANDARD_TABLE_PREFS_TABLE_NAME);
+ builder->select_add_field(GLOM_STANDARD_TABLE_PREFS_FIELD_ORG_ADDRESS_POSTCODE, GLOM_STANDARD_TABLE_PREFS_TABLE_NAME);
-
++
+ if(optional_org_logo)
+ {
+ builder->select_add_field(GLOM_STANDARD_TABLE_PREFS_FIELD_ORG_LOGO, GLOM_STANDARD_TABLE_PREFS_TABLE_NAME);
+ }
-
++
+ builder->select_add_target(GLOM_STANDARD_TABLE_PREFS_TABLE_NAME);
-
+
int attempts = 0;
while(attempts < 2)
{
@@@ -1031,9 -1253,9 +1254,9 @@@
#ifdef GLIBMM_EXCEPTIONS_ENABLED
try
{
- Glib::RefPtr<Gnome::Gda::DataModel> datamodel = query_execute_select(sql_query);
+ Glib::RefPtr<Gnome::Gda::DataModel> datamodel = query_execute_select(builder);
if(datamodel && (datamodel->get_n_rows() != 0))
- {
+ {
result.m_name = Conversions::get_text_for_gda_value(Field::TYPE_TEXT, datamodel->get_value_at(0, 0));
result.m_org_name = Conversions::get_text_for_gda_value(Field::TYPE_TEXT, datamodel->get_value_at(1, 0));
result.m_org_address_street = Conversions::get_text_for_gda_value(Field::TYPE_TEXT, datamodel->get_value_at(2, 0));
@@@ -1062,9 -1284,9 +1285,9 @@@
}
#else // GLIBMM_EXCEPTIONS_ENABLED
std::auto_ptr<Glib::Error> error;
- Glib::RefPtr<Gnome::Gda::DataModel> datamodel = query_execute_select(sql_query);
+ Glib::RefPtr<Gnome::Gda::DataModel> datamodel = query_execute_select(builder);
if(datamodel && (datamodel->get_n_rows() != 0))
- {
+ {
result.m_name = Conversions::get_text_for_gda_value(Field::TYPE_TEXT, datamodel->get_value_at(0, 0, error));
result.m_org_name = Conversions::get_text_for_gda_value(Field::TYPE_TEXT, datamodel->get_value_at(1, 0, error));
result.m_org_address_street = Conversions::get_text_for_gda_value(Field::TYPE_TEXT, datamodel->get_value_at(2, 0, error));
@@@ -1129,7 -1354,13 +1355,13 @@@ bool Base_DB::add_standard_tables() con
const Glib::ustring system_name = get_document()->get_database_title();
if(!system_name.empty())
{
- const bool test = query_execute("UPDATE \"" GLOM_STANDARD_TABLE_PREFS_TABLE_NAME "\" SET " "\"" GLOM_STANDARD_TABLE_PREFS_FIELD_NAME "\" = '" + system_name + "' WHERE \"" GLOM_STANDARD_TABLE_PREFS_FIELD_ID "\" = 1");
+ Glib::RefPtr<Gnome::Gda::SqlBuilder> builder = Gnome::Gda::SqlBuilder::create(Gnome::Gda::SQL_STATEMENT_UPDATE);
+ builder->set_table(GLOM_STANDARD_TABLE_PREFS_TABLE_NAME);
+ builder->add_field_value(GLOM_STANDARD_TABLE_PREFS_FIELD_NAME, system_name);
- builder->set_where(builder->add_cond(Gnome::Gda::SQL_OPERATOR_TYPE_EQ,
++ builder->set_where(builder->add_cond(Gnome::Gda::SQL_OPERATOR_TYPE_EQ,
+ builder->add_id(GLOM_STANDARD_TABLE_PREFS_FIELD_ID),
+ builder->add_expr(1)));
+ const bool test = query_execute(builder);
if(!test)
std::cerr << "Base_DB::add_standard_tables(): UPDATE failed." << std::endl;
}
@@@ -1289,37 -1520,28 +1521,27 @@@ void Base_DB::set_database_preferences(
{
if(get_userlevel() == AppState::USERLEVEL_DEVELOPER)
add_standard_tables();
-
+
- Glib::RefPtr<Gnome::Gda::Set> params = Gnome::Gda::Set::create();
- params->add_holder("name", prefs.m_name);
- params->add_holder("street", prefs.m_org_address_street);
- params->add_holder("street2", prefs.m_org_address_street2);
- params->add_holder("town", prefs.m_org_address_town);
- params->add_holder("county", prefs.m_org_address_county);
- params->add_holder("country", prefs.m_org_address_country);
- params->add_holder("postcode", prefs.m_org_address_postcode);
-
//The logo field was introduced in a later version of Glom.
//If the user is not in developer mode then the new field has not yet been added:
- Glib::ustring optional_part_logo;
+
+ Glib::RefPtr<Gnome::Gda::SqlBuilder> builder = Gnome::Gda::SqlBuilder::create(Gnome::Gda::SQL_STATEMENT_UPDATE);
+ builder->set_table(GLOM_STANDARD_TABLE_PREFS_TABLE_NAME);
+ builder->add_field_value(GLOM_STANDARD_TABLE_PREFS_FIELD_NAME, prefs.m_name);
+ builder->add_field_value(GLOM_STANDARD_TABLE_PREFS_FIELD_ORG_ADDRESS_STREET, prefs.m_org_address_street);
+ builder->add_field_value(GLOM_STANDARD_TABLE_PREFS_FIELD_ORG_ADDRESS_STREET2, prefs.m_org_address_street2);
+ builder->add_field_value(GLOM_STANDARD_TABLE_PREFS_FIELD_ORG_ADDRESS_TOWN, prefs.m_org_address_town);
+ builder->add_field_value(GLOM_STANDARD_TABLE_PREFS_FIELD_ORG_ADDRESS_COUNTY, prefs.m_org_address_county);
+ builder->add_field_value(GLOM_STANDARD_TABLE_PREFS_FIELD_ORG_ADDRESS_COUNTRY, prefs.m_org_address_country);
+ builder->add_field_value(GLOM_STANDARD_TABLE_PREFS_FIELD_ORG_ADDRESS_POSTCODE, prefs.m_org_address_postcode);
if(get_field_exists_in_database(GLOM_STANDARD_TABLE_PREFS_TABLE_NAME, GLOM_STANDARD_TABLE_PREFS_FIELD_ORG_LOGO))
{
- params->add_holder("org_logo", prefs.m_org_logo);
- optional_part_logo = "\"" GLOM_STANDARD_TABLE_PREFS_FIELD_ORG_LOGO "\" = ##org_logo::GDA_TYPE_BINARY, ";
+ builder->add_field_value(GLOM_STANDARD_TABLE_PREFS_FIELD_ORG_LOGO, prefs.m_org_logo);
- }
+ }
- const Glib::ustring sql_query = "UPDATE \"" GLOM_STANDARD_TABLE_PREFS_TABLE_NAME "\" SET "
- "\"" GLOM_STANDARD_TABLE_PREFS_FIELD_NAME "\" = ##name::gchararray, "
- + optional_part_logo +
- "\"" GLOM_STANDARD_TABLE_PREFS_FIELD_ORG_ADDRESS_STREET "\" = ##street::gchararray, "
- "\"" GLOM_STANDARD_TABLE_PREFS_FIELD_ORG_ADDRESS_STREET2 "\" = ##street2::gchararray, "
- "\"" GLOM_STANDARD_TABLE_PREFS_FIELD_ORG_ADDRESS_TOWN "\" = ##town::gchararray, "
- "\"" GLOM_STANDARD_TABLE_PREFS_FIELD_ORG_ADDRESS_COUNTY "\" = ##county::gchararray, "
- "\"" GLOM_STANDARD_TABLE_PREFS_FIELD_ORG_ADDRESS_COUNTRY "\" = ##country::gchararray, "
- "\"" GLOM_STANDARD_TABLE_PREFS_FIELD_ORG_ADDRESS_POSTCODE "\" = ##postcode::gchararray"
- " WHERE \"" GLOM_STANDARD_TABLE_PREFS_FIELD_ID "\" = 1";
-
- bool test = false;
- test = query_execute(sql_query, params);
+ builder->set_where(builder->add_cond(Gnome::Gda::SQL_OPERATOR_TYPE_EQ,
+ builder->add_id(GLOM_STANDARD_TABLE_PREFS_FIELD_ID),
+ builder->add_expr(1)));
- bool test = false;
- test = query_execute(builder);
++ bool test = query_execute(builder);
if(!test)
std::cerr << "Base_DB::set_database_preferences(): UPDATE failed." << std::endl;
@@@ -2445,8 -2600,11 +2635,11 @@@ void Base_DB::calculate_field_in_all_re
{
//Get primary key values for every record:
- const Glib::ustring query = "SELECT \"" + table_name + "\".\"" + primary_key->get_name() + "\" FROM \"" + table_name + "\"";
- Glib::RefPtr<Gnome::Gda::DataModel> data_model = query_execute_select(query);
+ Glib::RefPtr<Gnome::Gda::SqlBuilder> builder = Gnome::Gda::SqlBuilder::create(Gnome::Gda::SQL_STATEMENT_SELECT);
+ builder->select_add_field(primary_key->get_name(), table_name);
+ builder->select_add_target(table_name);
-
++
+ Glib::RefPtr<Gnome::Gda::DataModel> data_model = query_execute_select(builder);
if(!data_model || !data_model->get_n_rows() || !data_model->get_n_columns())
{
//HandleError();
@@@ -2749,14 -2900,13 +2942,13 @@@ bool Base_DB::set_field_value_in_databa
const Glib::ustring field_name = field_in_record.m_field->get_name();
if(!field_name.empty()) //This should not happen.
- {
+ {
- Glib::RefPtr<Gnome::Gda::Set> params = Gnome::Gda::Set::create();
- params->add_holder(field_in_record.m_field->get_holder(field_value));
- params->add_holder(field_in_record.m_key->get_holder(field_in_record.m_key_value));
-
- Glib::ustring strQuery = "UPDATE \"" + field_in_record.m_table_name + "\"";
- strQuery += " SET \"" + field_in_record.m_field->get_name() + "\" = " + field_in_record.m_field->get_gda_holder_string();
- strQuery += " WHERE \"" + field_in_record.m_key->get_name() + "\" = " + field_in_record.m_key->get_gda_holder_string();
+ Glib::RefPtr<Gnome::Gda::SqlBuilder> builder = Gnome::Gda::SqlBuilder::create(Gnome::Gda::SQL_STATEMENT_UPDATE);
+ builder->set_table(field_in_record.m_table_name);
+ builder->add_field_value_as_value(field_in_record.m_field->get_name(), field_value);
+ builder->set_where(builder->add_cond(Gnome::Gda::SQL_OPERATOR_TYPE_EQ,
+ builder->add_id(field_in_record.m_key->get_name()),
+ builder->add_expr_as_value(field_in_record.m_key_value)));
#ifdef GLIBMM_EXCEPTIONS_ENABLED
try //TODO: The exceptions are probably already handled by query_execute(0.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]