{
         struct cclassad *ad = NULL;
         char *extr_val = NULL;
+       char *extr_val_apostrophed = NULL;
 
         ad = cclassad_create(stat->jdl);
         if (ad) {
                 }
         }
 
-        //return extr_val ? extr_val : (char *) -1;
-        return extr_val;
+       if (extr_val) {
+               //XXX: To do this properly, it mayrequire some escaping
+               asprintf(&extr_val_apostrophed,"'%s'", extr_val);
+               free(extr_val);
+       }
+
+        return extr_val_apostrophed;
 }
 
 int edg_wll_ColumnToQueryRec(const char *col_name,edg_wll_QueryRec *rec)
 
                        if (val) {
                                char    *aux;
                                if (!cond_where) cond_where = strdup("");
-                               trio_asprintf(&aux, "%s or %s = '%s'",cond_where,
+                               trio_asprintf(&aux, "%s or %s = %s",cond_where,
                                                notif_index_cols[i].colname,val);
                                free(cond_where);
                                cond_where = aux;