glom r1931 - in trunk: . glom/libglom glom/libglom/connectionpool_backends glom/libglom/data_structure
- From: arminb svn gnome org
- To: svn-commits-list gnome org
- Subject: glom r1931 - in trunk: . glom/libglom glom/libglom/connectionpool_backends glom/libglom/data_structure
- Date: Tue, 24 Feb 2009 12:08:09 +0000 (UTC)
Author: arminb
Date: Tue Feb 24 12:08:09 2009
New Revision: 1931
URL: http://svn.gnome.org/viewvc/glom?rev=1931&view=rev
Log:
2009-02-24 Armin Burgmeier <armin openismus com>
* glom/libglom/connectionpool.h:
* glom/libglom/connectionpool.cc: Added a get_string_find_operator()
virtual method to ConnectionPoolBackend, and a similar method to
ConnectionPool which simply queries its backend.
* glom/libglom/connectionpool_backends/sqlite.h:
* glom/libglom/connectionpool_backends/postgres.h: Implement the new
virtual method appropriately.
* glom/libglom/data_structure/field.cc (sql_find_operator): Use the
get_string_find_operator() method of the connectionpool backend in
case the field's type is TYPE_TEXT. This fixes Find Mode with SQLite.
Bug #570401. I wonder whether libgda can generate a case-insensitive
string comparison, which would make this easier for us.
Modified:
trunk/ChangeLog
trunk/glom/libglom/connectionpool.cc
trunk/glom/libglom/connectionpool.h
trunk/glom/libglom/connectionpool_backends/postgres.h
trunk/glom/libglom/connectionpool_backends/sqlite.h
trunk/glom/libglom/data_structure/field.cc
Modified: trunk/glom/libglom/connectionpool.cc
==============================================================================
--- trunk/glom/libglom/connectionpool.cc (original)
+++ trunk/glom/libglom/connectionpool.cc Tue Feb 24 12:08:09 2009
@@ -719,6 +719,12 @@
return m_pFieldTypes;
}
+Glib::ustring ConnectionPool::get_string_find_operator() const
+{
+ g_assert(m_backend.get());
+ return m_backend->get_string_find_operator();
+}
+
void ConnectionPool::on_sharedconnection_finished()
{
//g_warning("ConnectionPool::on_sharedconnection_finished().");
Modified: trunk/glom/libglom/connectionpool.h
==============================================================================
--- trunk/glom/libglom/connectionpool.h (original)
+++ trunk/glom/libglom/connectionpool.h Tue Feb 24 12:08:09 2009
@@ -130,11 +130,19 @@
*/
virtual Field::sql_format get_sql_format() const = 0;
- /* Whether the database can be accessed from remote machines, once startup()
+ /** Whether the database can be accessed from remote machines, once startup()
* was called.
*/
virtual bool supports_remote_access() const = 0;
+ /** The operator to use to compare strings in a case-independant way. This
+ * is backend-depandent. For example, postgres uses ILIKE but SQLite uses
+ * LIKE.
+ * TODO: Maybe we can use libgda to construct the expression, so we don't
+ * need this function.
+ */
+ virtual Glib::ustring get_string_find_operator() const = 0;
+
/** This method is called for one-time initialization of the database
* storage. No need to implement this function if the data is centrally
* hosted, not managed by Glom.
@@ -242,6 +250,7 @@
Field::sql_format get_sql_format() const;
const FieldTypes* get_field_types() const;
+ Glib::ustring get_string_find_operator() const;
/** Do one-time initialization, such as creating required database
* files on disk for later use by their own database server instance.
Modified: trunk/glom/libglom/connectionpool_backends/postgres.h
==============================================================================
--- trunk/glom/libglom/connectionpool_backends/postgres.h (original)
+++ trunk/glom/libglom/connectionpool_backends/postgres.h Tue Feb 24 12:08:09 2009
@@ -55,6 +55,7 @@
protected:
virtual Field::sql_format get_sql_format() const { return Field::SQL_FORMAT_POSTGRES; }
virtual bool supports_remote_access() const { return true; }
+ virtual Glib::ustring get_string_find_operator() const { return "ILIKE"; } // ILIKE is a postgres extension for locale-dependent case-insensitive matches.
#ifndef GLOM_ENABLE_CLIENT_ONLY
virtual bool change_columns(const Glib::RefPtr<Gnome::Gda::Connection>& connection, const Glib::ustring& table_name, const type_vecConstFields& old_fields, const type_vecConstFields& new_fields, std::auto_ptr<Glib::Error>& error);
Modified: trunk/glom/libglom/connectionpool_backends/sqlite.h
==============================================================================
--- trunk/glom/libglom/connectionpool_backends/sqlite.h (original)
+++ trunk/glom/libglom/connectionpool_backends/sqlite.h Tue Feb 24 12:08:09 2009
@@ -47,6 +47,7 @@
protected:
virtual Field::sql_format get_sql_format() const { return Field::SQL_FORMAT_SQLITE; }
virtual bool supports_remote_access() const { return false; }
+ virtual Glib::ustring get_string_find_operator() const { return "LIKE"; }
#ifndef GLOM_ENABLE_CLIENT_ONLY
bool add_column_to_server_operation(const Glib::RefPtr<Gnome::Gda::ServerOperation>& operation, GdaMetaTableColumn* column, unsigned int i, std::auto_ptr<Glib::Error>& error);
Modified: trunk/glom/libglom/data_structure/field.cc
==============================================================================
--- trunk/glom/libglom/data_structure/field.cc (original)
+++ trunk/glom/libglom/data_structure/field.cc Tue Feb 24 12:08:09 2009
@@ -367,7 +367,11 @@
{
case(TYPE_TEXT):
{
- return "ILIKE"; //"LIKE"; ILIKE is a postgres extension for locale-dependent case-insensitive matches.
+ ConnectionPool* connection_pool = ConnectionPool::get_instance();
+ if(connection_pool && connection_pool->get_backend())
+ return connection_pool->get_string_find_operator();
+ else
+ return "LIKE"; // Default
break;
}
case(TYPE_DATE):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]