[gom] gom: Don't consider a property mapped if type is not handled



commit 0ba7e8910c6c151346c22b1d07b66dea896ed9db
Author: Bastien Nocera <hadess hadess net>
Date:   Tue Apr 15 15:45:49 2014 +0200

    gom: Don't consider a property mapped if type is not handled
    
    If the type for a property is not one of the fundamental types that
    we know how to handle, don't map it in the command builder.

 gom/gom-command-builder.c |   24 ++++++++++++++++++++++++
 1 files changed, 24 insertions(+), 0 deletions(-)
---
diff --git a/gom/gom-command-builder.c b/gom/gom-command-builder.c
index edd13db..9ef9fcb 100644
--- a/gom/gom-command-builder.c
+++ b/gom/gom-command-builder.c
@@ -52,6 +52,25 @@ enum
 
 static GParamSpec *gParamSpecs[LAST_PROP];
 
+static const char *
+sql_type_for_column (GParamSpec *pspec)
+{
+   switch (pspec->value_type) {
+   case G_TYPE_INT:
+   case G_TYPE_INT64:
+   case G_TYPE_UINT:
+   case G_TYPE_UINT64:
+      return "INTEGER";
+   case G_TYPE_STRING:
+      return "TEXT";
+   case G_TYPE_FLOAT:
+   case G_TYPE_DOUBLE:
+      return "FLOAT";
+   default:
+      return FALSE;
+   }
+}
+
 static gboolean
 is_mapped (GParamSpec *pspec)
 {
@@ -62,6 +81,11 @@ is_mapped (GParamSpec *pspec)
     *       fields they want mapped.
     */
    ret = (pspec->owner_type != GOM_TYPE_RESOURCE);
+   if (!ret)
+     return FALSE;
+
+   ret = (sql_type_for_column(pspec) != NULL);
+
    return ret;
 }
 


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