[glom] Added ConnectionPool::set_fake_connection().



commit 62fc98c88bb487d390fc569aac7b6db80d53bd5a
Author: Murray Cumming <murrayc murrayc com>
Date:   Thu Nov 10 12:58:12 2011 +0100

    Added ConnectionPool::set_fake_connection().
    
    * glom/libglom/connectionpool_backends/backend.h: connect():
    * glom/libglom/connectionpool_backends/postgres.[h|cc]: connect(),
    attempt_connect():
    * glom/libglom/connectionpool_backends/postgres_central.[h|cc]: connect():
    * glom/libglom/connectionpool_backends/postgres_self.[h|cc]: connect():
    * glom/libglom/connectionpool_backends/sqlite.[h|cc]: connect():
    Add a bool fake_connection parameter and use Gnome::Gda::create_with_string()
    instead of open_with_string() if it is true.
    * glom/libglom/connectionpool.[h|cc]: Add set_fake_connection() to set
    that bool and other things needed to make it work.
    
    * Makefile_tests.am:
    * tests/test_fake_connection.cc: Added a test that uses this for the
    intended purpose of getting a suitable SQL query string without an open
    connection.
    However, it does not currently work as expected due to:
    http://mail.gnome.org/archives/gnome-db-list/2011-November/msg00007.html

 ChangeLog                                          |   22 +++++
 Makefile_tests.am                                  |    7 +-
 glom/libglom/connectionpool.cc                     |   17 +++-
 glom/libglom/connectionpool.h                      |   10 ++-
 glom/libglom/connectionpool_backends/backend.h     |   12 +--
 glom/libglom/connectionpool_backends/postgres.cc   |   23 +++--
 glom/libglom/connectionpool_backends/postgres.h    |    2 +-
 .../connectionpool_backends/postgres_central.cc    |    6 +-
 .../connectionpool_backends/postgres_central.h     |    2 +-
 .../connectionpool_backends/postgres_self.cc       |    4 +-
 .../connectionpool_backends/postgres_self.h        |    2 +-
 glom/libglom/connectionpool_backends/sqlite.cc     |   17 +++-
 glom/libglom/connectionpool_backends/sqlite.h      |    2 +-
 tests/test_fake_connection.cc                      |   99 ++++++++++++++++++++
 14 files changed, 193 insertions(+), 32 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 85e9166..5d74ce2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,27 @@
 2011-11-10  Murray Cumming  <murrayc murrayc com>
 
+	Added ConnectionPool::set_fake_connection().
+
+	* glom/libglom/connectionpool_backends/backend.h: connect():
+	* glom/libglom/connectionpool_backends/postgres.[h|cc]: connect(),
+	attempt_connect():
+	* glom/libglom/connectionpool_backends/postgres_central.[h|cc]: connect():
+	* glom/libglom/connectionpool_backends/postgres_self.[h|cc]: connect():
+	* glom/libglom/connectionpool_backends/sqlite.[h|cc]: connect():
+	Add a bool fake_connection parameter and use Gnome::Gda::create_with_string()
+	instead of open_with_string() if it is true.
+	* glom/libglom/connectionpool.[h|cc]: Add set_fake_connection() to set 
+	that bool and other things needed to make it work.	
+
+	* Makefile_tests.am:
+	* tests/test_fake_connection.cc: Added a test that uses this for the 
+	intended purpose of getting a suitable SQL query string without an open 
+	connection.
+	However, it does not currently work as expected due to:
+	http://mail.gnome.org/archives/gnome-db-list/2011-November/msg00007.html
+
+2011-11-10  Murray Cumming  <murrayc murrayc com>
+
 	Escape database connection details properly.
 
 	* glom/libglom/db_utils.[h|cc]: Added gda_cnc_string_encode() for use 
diff --git a/Makefile_tests.am b/Makefile_tests.am
index 74f333f..06a88af 100644
--- a/Makefile_tests.am
+++ b/Makefile_tests.am
@@ -25,6 +25,7 @@ check_PROGRAMS =						\
 	tests/test_signal_reemit			\
 	tests/python/test_load_python_library\
 	tests/python/test_python_module \
+	tests/test_fake_connection \
 	tests/test_selfhosting_new_empty \
 	tests/test_selfhosting_new_from_example \
 	tests/test_selfhosting_new_from_example_strangepath \
@@ -47,6 +48,7 @@ TESTS =	tests/test_document_load	\
 	tests/test_xslt_file_validation.sh \
 	tests/python/test_load_python_library \
 	tests/python/test_python_module \
+	tests/test_fake_connection \
 	tests/test_selfhosting_new_empty \
 	tests/test_selfhosting_new_from_example \
 	tests/test_selfhosting_new_from_example_strangepath \
@@ -142,6 +144,10 @@ tests_import_test_signals_CPPFLAGS = $(tests_cppflags)
 sources_test_selfhosting_utils = tests/test_selfhosting_utils.h \
 	tests/test_selfhosting_utils.cc
 
+tests_test_fake_connection_SOURCES = tests/test_fake_connection.cc
+tests_test_fake_connection_LDADD = $(tests_ldadd)
+tests_test_fake_connection_CPPFLAGS = $(tests_cppflags)
+
 tests_test_selfhosting_new_empty_SOURCES = tests/test_selfhosting_new_empty.cc
 tests_test_selfhosting_new_empty_LDADD = $(tests_ldadd)
 tests_test_selfhosting_new_empty_CPPFLAGS = $(tests_cppflags)
@@ -150,7 +156,6 @@ tests_test_selfhosting_new_from_example_SOURCES = tests/test_selfhosting_new_fro
 tests_test_selfhosting_new_from_example_LDADD = $(tests_ldadd)
 tests_test_selfhosting_new_from_example_CPPFLAGS = $(tests_cppflags)
 
-
 tests_test_selfhosting_new_from_example_strangepath_SOURCES = tests/test_selfhosting_new_from_example_strangepath.cc $(sources_test_selfhosting_utils)
 tests_test_selfhosting_new_from_example_strangepath_LDADD = $(tests_ldadd)
 tests_test_selfhosting_new_from_example_strangepath_CPPFLAGS = $(tests_cppflags)
diff --git a/glom/libglom/connectionpool.cc b/glom/libglom/connectionpool.cc
index dae8533..dc676f5 100644
--- a/glom/libglom/connectionpool.cc
+++ b/glom/libglom/connectionpool.cc
@@ -112,7 +112,8 @@ ConnectionPool::ConnectionPool()
   m_ready_to_connect(false),
   m_pFieldTypes(0),
   m_show_debug_output(false),
-  m_auto_server_shutdown(true)
+  m_auto_server_shutdown(true),
+  m_fake_connection(false)
 {
 }
 
@@ -270,7 +271,7 @@ sharedptr<SharedConnection> ConnectionPool::connect()
   //Don't try to connect if we don't have a backend to connect to.
   g_return_val_if_fail(m_backend.get(), sharedptr<SharedConnection>(0));
 
-  if(get_ready_to_connect())
+  if(get_ready_to_connect() || m_fake_connection)
   {
     if(connection_cached)
     {
@@ -304,9 +305,10 @@ sharedptr<SharedConnection> ConnectionPool::connect()
     }
     else
     {
+      if(m_fake_connection)
       try
       {
-        m_refGdaConnection = m_backend->connect(m_database, get_user(), get_password());
+        m_refGdaConnection = m_backend->connect(m_database, get_user(), get_password(), m_fake_connection);
       }
       catch(const Glib::Error& ex)
       {
@@ -941,4 +943,13 @@ void ConnectionPool::set_auto_server_shutdown(bool val)
   m_auto_server_shutdown = val;
 }
 
+void ConnectionPool::set_fake_connection()
+{
+  m_fake_connection = true;
+
+  //Set a fake username and password, to avoid a GError from gda_connection_new_from_string():
+  set_user("glom_fake_user");
+  set_password("glom_fake_password");
+}
+
 } //namespace Glom
diff --git a/glom/libglom/connectionpool.h b/glom/libglom/connectionpool.h
index 685409e..f9d2937 100644
--- a/glom/libglom/connectionpool.h
+++ b/glom/libglom/connectionpool.h
@@ -124,10 +124,16 @@ public:
   void set_avahi_publish_callbacks(const type_void_slot& slot_begin, const type_void_slot& slot_progress, const type_void_slot& slot_done);
 #endif
 
-
   bool get_ready_to_connect() const;
   void set_ready_to_connect(bool val = true);
 
+  /** Do not actually connect to the database,
+   * but create a Gnome::Gda::Connection object
+   * just so that utility functions such as Utils::sqlbuilder_get_full_query()
+   * and DbUtils::escape_sql_id() can work.
+   */
+  void set_fake_connection();
+
   void set_backend(std::auto_ptr<Backend> backend);
 
   Backend* get_backend();
@@ -304,6 +310,8 @@ private:
   FieldTypes* m_pFieldTypes;
   bool m_show_debug_output, m_auto_server_shutdown;
 
+  bool m_fake_connection;
+
 private:
 
   static ConnectionPool* m_instance;
diff --git a/glom/libglom/connectionpool_backends/backend.h b/glom/libglom/connectionpool_backends/backend.h
index 46a5666..a3dba7f 100644
--- a/glom/libglom/connectionpool_backends/backend.h
+++ b/glom/libglom/connectionpool_backends/backend.h
@@ -166,14 +166,12 @@ protected:
   virtual bool set_network_shared(const SlotProgress& slot_progress, bool network_shared = true);
 
   /** This method is called to create a connection to the database server.
-   * There exists only the variant with an error variable as last parameter
-   * so we don't need #ifdefs all over the code. This part of the API is only
-   * used by the ConnectionPool which will translate the error back into
-   * an exception in case exceptions are enabled.
-   * If this method doesn't return a connection handle then error will be
-   * non-zero (and vice versa).
-   */
-  virtual Glib::RefPtr<Gnome::Gda::Connection> connect(const Glib::ustring& database, const Glib::ustring& username, const Glib::ustring& password) = 0;
+   *
+   * @param fake_connection Whether the connection should not actually be opened.
+   *
+   * @throws An ExceptionConnection if the correction failed.
+   */
+  virtual Glib::RefPtr<Gnome::Gda::Connection> connect(const Glib::ustring& database, const Glib::ustring& username, const Glib::ustring& password, bool fake_connection = false) = 0;
 
   /** @throws Glib::Error (from libgdamm)
    */
diff --git a/glom/libglom/connectionpool_backends/postgres.cc b/glom/libglom/connectionpool_backends/postgres.cc
index df2e582..a6b8ee9 100644
--- a/glom/libglom/connectionpool_backends/postgres.cc
+++ b/glom/libglom/connectionpool_backends/postgres.cc
@@ -64,7 +64,7 @@ Postgres::Postgres()
 {
 }
 
-Glib::RefPtr<Gnome::Gda::Connection> Postgres::attempt_connect(const Glib::ustring& port, const Glib::ustring& database, const Glib::ustring& username, const Glib::ustring& password)
+Glib::RefPtr<Gnome::Gda::Connection> Postgres::attempt_connect(const Glib::ustring& port, const Glib::ustring& database, const Glib::ustring& username, const Glib::ustring& password, bool fake_connection)
 {
   //We must specify _some_ database even when we just want to create a database.
   //This _might_ be different on some systems. I hope not. murrayc
@@ -87,12 +87,21 @@ Glib::RefPtr<Gnome::Gda::Connection> Postgres::attempt_connect(const Glib::ustri
 
   try
   {
-    connection = Gnome::Gda::Connection::open_from_string("PostgreSQL",
-      cnc_string, auth_string,
-      Gnome::Gda::CONNECTION_OPTIONS_SQL_IDENTIFIERS_CASE_SENSITIVE
-      );
-    connection->statement_execute_non_select("SET DATESTYLE = 'ISO'");
-    data_model = connection->statement_execute_select("SELECT version()");
+    if(fake_connection)
+    {
+      connection = Gnome::Gda::Connection::create_from_string("PostgreSQL",
+        cnc_string, auth_string,
+        Gnome::Gda::CONNECTION_OPTIONS_SQL_IDENTIFIERS_CASE_SENSITIVE);
+    }
+    else
+    {
+      connection = Gnome::Gda::Connection::open_from_string("PostgreSQL",
+        cnc_string, auth_string,
+        Gnome::Gda::CONNECTION_OPTIONS_SQL_IDENTIFIERS_CASE_SENSITIVE);
+
+      connection->statement_execute_non_select("SET DATESTYLE = 'ISO'");
+      data_model = connection->statement_execute_select("SELECT version()");
+    }
   }
   catch(const Glib::Error& ex)
   {
diff --git a/glom/libglom/connectionpool_backends/postgres.h b/glom/libglom/connectionpool_backends/postgres.h
index fc0abb3..6e79f65 100644
--- a/glom/libglom/connectionpool_backends/postgres.h
+++ b/glom/libglom/connectionpool_backends/postgres.h
@@ -71,7 +71,7 @@ protected:
   /** Attempt to connect to the database with the specified criteria.
    * @throws An ExceptionConnection if the correction failed.
    */ 
-  Glib::RefPtr<Gnome::Gda::Connection> attempt_connect(const Glib::ustring& port, const Glib::ustring& database, const Glib::ustring& username, const Glib::ustring& password);
+  Glib::RefPtr<Gnome::Gda::Connection> attempt_connect(const Glib::ustring& port, const Glib::ustring& database, const Glib::ustring& username, const Glib::ustring& password, bool fake_connection);
 
  std::string get_self_hosting_path(bool create = false, const std::string& child_directory = std::string());
 
diff --git a/glom/libglom/connectionpool_backends/postgres_central.cc b/glom/libglom/connectionpool_backends/postgres_central.cc
index ab6ea33..fd76f1b 100644
--- a/glom/libglom/connectionpool_backends/postgres_central.cc
+++ b/glom/libglom/connectionpool_backends/postgres_central.cc
@@ -81,7 +81,7 @@ bool PostgresCentralHosted::get_try_other_ports() const
   return m_try_other_ports;
 }
 
-Glib::RefPtr<Gnome::Gda::Connection> PostgresCentralHosted::connect(const Glib::ustring& database, const Glib::ustring& username, const Glib::ustring& password)
+Glib::RefPtr<Gnome::Gda::Connection> PostgresCentralHosted::connect(const Glib::ustring& database, const Glib::ustring& username, const Glib::ustring& password, bool fake_connection)
 {
   Glib::RefPtr<Gnome::Gda::Connection> connection;
 
@@ -96,7 +96,7 @@ Glib::RefPtr<Gnome::Gda::Connection> PostgresCentralHosted::connect(const Glib::
   bool connection_possible = false;
   try
   {
-    connection = attempt_connect(port, database, username, password);
+    connection = attempt_connect(port, database, username, password, fake_connection);
     connection_possible = true;
     m_port = atoi(port.c_str());
   }
@@ -120,7 +120,7 @@ Glib::RefPtr<Gnome::Gda::Connection> PostgresCentralHosted::connect(const Glib::
 
       try
       {
-        connection = attempt_connect(port, database, username, password);
+        connection = attempt_connect(port, database, username, password, fake_connection);
         connection_possible = true;
         m_port = atoi(port.c_str());
       }
diff --git a/glom/libglom/connectionpool_backends/postgres_central.h b/glom/libglom/connectionpool_backends/postgres_central.h
index 78d3215..ef45c62 100644
--- a/glom/libglom/connectionpool_backends/postgres_central.h
+++ b/glom/libglom/connectionpool_backends/postgres_central.h
@@ -48,7 +48,7 @@ public:
   bool get_try_other_ports() const;
 
 private:
-  virtual Glib::RefPtr<Gnome::Gda::Connection> connect(const Glib::ustring& database, const Glib::ustring& username, const Glib::ustring& password);
+  virtual Glib::RefPtr<Gnome::Gda::Connection> connect(const Glib::ustring& database, const Glib::ustring& username, const Glib::ustring& password, bool fake_connection = false);
 
   virtual bool create_database(const Glib::ustring& database_name, const Glib::ustring& username, const Glib::ustring& password);
 
diff --git a/glom/libglom/connectionpool_backends/postgres_self.cc b/glom/libglom/connectionpool_backends/postgres_self.cc
index 1ba19ba..7ae964a 100644
--- a/glom/libglom/connectionpool_backends/postgres_self.cc
+++ b/glom/libglom/connectionpool_backends/postgres_self.cc
@@ -605,7 +605,7 @@ static bool on_timeout_delay(const Glib::RefPtr<Glib::MainLoop>& mainloop)
 }
 
 
-Glib::RefPtr<Gnome::Gda::Connection> PostgresSelfHosted::connect(const Glib::ustring& database, const Glib::ustring& username, const Glib::ustring& password)
+Glib::RefPtr<Gnome::Gda::Connection> PostgresSelfHosted::connect(const Glib::ustring& database, const Glib::ustring& username, const Glib::ustring& password, bool fake_connection)
 {
   if(!get_self_hosting_active())
   {
@@ -622,7 +622,7 @@ Glib::RefPtr<Gnome::Gda::Connection> PostgresSelfHosted::connect(const Glib::ust
   {
     try
     {
-      result = attempt_connect(port_as_string(m_port), database, username, password);
+      result = attempt_connect(port_as_string(m_port), database, username, password, fake_connection);
     }
     catch(const ExceptionConnection& ex)
     {
diff --git a/glom/libglom/connectionpool_backends/postgres_self.h b/glom/libglom/connectionpool_backends/postgres_self.h
index b36f750..d5666f8 100644
--- a/glom/libglom/connectionpool_backends/postgres_self.h
+++ b/glom/libglom/connectionpool_backends/postgres_self.h
@@ -61,7 +61,7 @@ private:
   virtual bool cleanup(const SlotProgress& slot_progress);
   virtual bool set_network_shared(const SlotProgress& slot_progress, bool network_shared = true);
 
-  virtual Glib::RefPtr<Gnome::Gda::Connection> connect(const Glib::ustring& database, const Glib::ustring& username, const Glib::ustring& password);
+  virtual Glib::RefPtr<Gnome::Gda::Connection> connect(const Glib::ustring& database, const Glib::ustring& username, const Glib::ustring& password, bool fake_connection = false);
 
   virtual bool create_database(const Glib::ustring& database_name, const Glib::ustring& username, const Glib::ustring& password);
 
diff --git a/glom/libglom/connectionpool_backends/sqlite.cc b/glom/libglom/connectionpool_backends/sqlite.cc
index 1af915f..acb85c5 100644
--- a/glom/libglom/connectionpool_backends/sqlite.cc
+++ b/glom/libglom/connectionpool_backends/sqlite.cc
@@ -37,7 +37,7 @@ Sqlite::Sqlite()
 {
 }
 
-Glib::RefPtr<Gnome::Gda::Connection> Sqlite::connect(const Glib::ustring& database, const Glib::ustring& username, const Glib::ustring& password)
+Glib::RefPtr<Gnome::Gda::Connection> Sqlite::connect(const Glib::ustring& database, const Glib::ustring& username, const Glib::ustring& password, bool fake_connection)
 {
   Glib::RefPtr<Gnome::Gda::Connection> connection;
   if(m_database_directory_uri.empty())
@@ -71,9 +71,18 @@ Glib::RefPtr<Gnome::Gda::Connection> Sqlite::connect(const Glib::ustring& databa
       const Glib::ustring auth_string = Glib::ustring::compose("USERNAME=%1;PASSWORD=%2", 
         DbUtils::gda_cnc_string_encode(username), DbUtils::gda_cnc_string_encode(password));
 
-      connection = Gnome::Gda::Connection::open_from_string("SQLite",
-        cnc_string, auth_string,
-        Gnome::Gda::CONNECTION_OPTIONS_SQL_IDENTIFIERS_CASE_SENSITIVE);
+      if(fake_connection)
+      {
+         connection = Gnome::Gda::Connection::create_from_string("SQLite",
+          cnc_string, auth_string,
+          Gnome::Gda::CONNECTION_OPTIONS_SQL_IDENTIFIERS_CASE_SENSITIVE);
+      }
+      else
+      {
+        connection = Gnome::Gda::Connection::open_from_string("SQLite",
+          cnc_string, auth_string,
+          Gnome::Gda::CONNECTION_OPTIONS_SQL_IDENTIFIERS_CASE_SENSITIVE);
+      }
     }
   }
 
diff --git a/glom/libglom/connectionpool_backends/sqlite.h b/glom/libglom/connectionpool_backends/sqlite.h
index 52c0850..a7bc2d5 100644
--- a/glom/libglom/connectionpool_backends/sqlite.h
+++ b/glom/libglom/connectionpool_backends/sqlite.h
@@ -56,7 +56,7 @@ private:
   virtual bool drop_column(const Glib::RefPtr<Gnome::Gda::Connection>& connection, const Glib::ustring& table_name, const Glib::ustring& field_name);
   virtual bool change_columns(const Glib::RefPtr<Gnome::Gda::Connection>& connection, const Glib::ustring& table_name, const type_vec_const_fields& old_fields, const type_vec_const_fields& new_fields) throw();
 
-  virtual Glib::RefPtr<Gnome::Gda::Connection> connect(const Glib::ustring& database, const Glib::ustring& username, const Glib::ustring& password);
+  virtual Glib::RefPtr<Gnome::Gda::Connection> connect(const Glib::ustring& database, const Glib::ustring& username, const Glib::ustring& password, bool fake_connection = false);
 
   /** Creates a new database.
    */
diff --git a/tests/test_fake_connection.cc b/tests/test_fake_connection.cc
new file mode 100644
index 0000000..76cc7f7
--- /dev/null
+++ b/tests/test_fake_connection.cc
@@ -0,0 +1,99 @@
+/* Glom
+ *
+ * Copyright (C) 2010 Openismus GmbH
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+71 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include <libglom/document/document.h>
+#include <libglom/init.h>
+#include <libglom/utils.h>
+#include <libglom/db_utils.h>
+#include <libglom/connectionpool.h>
+#include <libglom/connectionpool_backends/postgres_central.h>
+#include <giomm/file.h>
+#include <glibmm/convert.h>
+#include <glibmm/miscutils.h>
+
+#include <iostream>
+
+int main()
+{
+  Glom::libglom_init();
+
+  // Get a URI for a test file:
+  Glib::ustring uri;
+
+  try
+  {
+    const std::string path =
+       Glib::build_filename(GLOM_DOCDIR_EXAMPLES_NOTINSTALLED,
+         "example_music_collection.glom");
+    uri = Glib::filename_to_uri(path);
+  }
+  catch(const Glib::ConvertError& ex)
+  {
+    std::cerr << G_STRFUNC << ": " << ex.what();
+    return EXIT_FAILURE;
+  }
+
+  // Load the document:
+  Glom::Document document;
+  document.set_file_uri(uri);
+  int failure_code = 0;
+  const bool test = document.load(failure_code);
+  //std::cout << "Document load result=" << test << std::endl;
+
+  if(!test)
+  {
+    std::cerr << "Document::load() failed with failure_code=" << failure_code << std::endl;
+    return EXIT_FAILURE;
+  }
+
+  //Allow a fake connection, so sqlbuilder_get_full_query() can work:
+  Glom::ConnectionPool* connection_pool = Glom::ConnectionPool::get_instance();
+  Glom::ConnectionPoolBackends::Backend* backend = 
+    new Glom::ConnectionPoolBackends::PostgresCentralHosted();
+  connection_pool->set_backend(std::auto_ptr<Glom::ConnectionPool::Backend>(backend));
+  connection_pool->set_fake_connection();
+
+  //Build a SQL query and get the string for it:
+  //Try to get more rows than intended:
+  const Gnome::Gda::Value value("Born To Run");
+  Glom::sharedptr<const Glom::Field> where_field = document.get_field("albums", "name");
+  const Gnome::Gda::SqlExpr where_clause = 
+    Glom::Utils::build_simple_where_expression("albums", where_field, value);
+  
+  Glom::Utils::type_vecLayoutFields fieldsToGet;
+  Glom::sharedptr<const Glom::Field> field = document.get_field("albums", "album_id");
+  Glom::sharedptr<Glom::LayoutItem_Field> layoutitem = Glom::sharedptr<Glom::LayoutItem_Field>::create();
+  layoutitem->set_full_field_details(field);
+  fieldsToGet.push_back(layoutitem);
+  field = document.get_field("albums", "name");
+  layoutitem = Glom::sharedptr<Glom::LayoutItem_Field>::create();
+  layoutitem->set_full_field_details(field);
+  fieldsToGet.push_back(layoutitem);
+
+  const Glib::RefPtr<const Gnome::Gda::SqlBuilder> builder = 
+    Glom::Utils::build_sql_select_with_where_clause("albums",
+      fieldsToGet, where_clause);
+  const Glib::ustring& query = Glom::Utils::sqlbuilder_get_full_query(builder);
+  std::cout << "query: " << query << std::endl;
+
+  Glom::libglom_deinit();
+
+  return EXIT_SUCCESS;
+}



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