[tracker/wip/carlosg/serialize-api: 20/36] libtracker-data: Use SQL value type as a last resort to determine column type




commit 9005b341321f7429fd786e3b47e8c5a6d8965b43
Author: Carlos Garnacho <carlosg gnome org>
Date:   Sun Nov 21 11:34:53 2021 +0100

    libtracker-data: Use SQL value type as a last resort to determine column type
    
    Since all values in SQLite are neatly transformable to strings, we resorted
    to those if we could not know the underlying type. Look up the SQLite value
    type for that column as a last resort, so we have better chances of getting
    it right.

 src/libtracker-data/tracker-db-interface-sqlite.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
---
diff --git a/src/libtracker-data/tracker-db-interface-sqlite.c 
b/src/libtracker-data/tracker-db-interface-sqlite.c
index 13a7861a7..31f7d9f68 100644
--- a/src/libtracker-data/tracker-db-interface-sqlite.c
+++ b/src/libtracker-data/tracker-db-interface-sqlite.c
@@ -3617,7 +3617,14 @@ tracker_db_cursor_get_value_type (TrackerDBCursor *cursor,
                }
        }
 
-        return TRACKER_SPARQL_VALUE_TYPE_STRING;
+       switch (column_type) {
+       case SQLITE_INTEGER:
+               return TRACKER_SPARQL_VALUE_TYPE_INTEGER;
+       case SQLITE_FLOAT:
+               return TRACKER_SPARQL_VALUE_TYPE_DOUBLE;
+       default:
+               return TRACKER_SPARQL_VALUE_TYPE_STRING;
+       }
 }
 
 const gchar*


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