[tracker/rss-enclosures] SPARQL: Use COLLATE in SQL for variables and property functions



commit 841835693c441c99c62dbd4d85bb791127cf1738
Author: Jürg Billeter <j bitron ch>
Date:   Tue Oct 5 16:00:22 2010 +0200

    SPARQL: Use COLLATE in SQL for variables and property functions
    
    This fixes collation when subselects are involved.
    
    Fixes NB#195394.

 src/libtracker-data/libtracker-data.vapi           |    3 +++
 src/libtracker-data/tracker-sparql-expression.vala |   11 +++++++++++
 2 files changed, 14 insertions(+), 0 deletions(-)
---
diff --git a/src/libtracker-data/libtracker-data.vapi b/src/libtracker-data/libtracker-data.vapi
index 6902c54..63c2f6b 100644
--- a/src/libtracker-data/libtracker-data.vapi
+++ b/src/libtracker-data/libtracker-data.vapi
@@ -153,5 +153,8 @@ namespace Tracker {
 		public bool init (DBManagerFlags flags, [CCode (array_length = false)] string[]? test_schema, out bool first_time, bool journal_check, uint select_cache_size, uint update_cache_size, BusyCallback? busy_callback, string? busy_status);
 		public void shutdown ();
 	}
+
+	[CCode (cheader_filename = "libtracker-data/tracker-db-interface-sqlite.h")]
+	public const string COLLATION_NAME;
 }
 
diff --git a/src/libtracker-data/tracker-sparql-expression.vala b/src/libtracker-data/tracker-sparql-expression.vala
index 1fa3630..ce4103b 100644
--- a/src/libtracker-data/tracker-sparql-expression.vala
+++ b/src/libtracker-data/tracker-sparql-expression.vala
@@ -73,6 +73,10 @@ class Tracker.Sparql.Expression : Object {
 		return (type == PropertyType.INTEGER || type == PropertyType.DOUBLE || type == PropertyType.DATETIME || type == PropertyType.UNKNOWN);
 	}
 
+	void append_collate (StringBuilder sql) {
+		sql.append_printf (" COLLATE %s", COLLATION_NAME);
+	}
+
 	void skip_bracketted_expression () throws Sparql.Error {
 		expect (SparqlTokenType.OPEN_PARENS);
 		while (true) {
@@ -668,6 +672,10 @@ class Tracker.Sparql.Expression : Object {
 				translate_expression (sql);
 				sql.append (")");
 
+				if (prop.data_type == PropertyType.STRING) {
+					append_collate (sql);
+				}
+
 				return prop.data_type;
 			}
 		}
@@ -888,6 +896,9 @@ class Tracker.Sparql.Expression : Object {
 			if (variable.binding == null) {
 				return PropertyType.UNKNOWN;
 			} else {
+				if (variable.binding.data_type == PropertyType.STRING) {
+					append_collate (sql);
+				}
 				return variable.binding.data_type;
 			}
 		case SparqlTokenType.STR:



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