Builder/Provider/Database/generate.js
[app.Builder.js] / Builder / Provider / Database / generate.js
index e8107c6..2275012 100644 (file)
@@ -75,8 +75,8 @@ Gda.DataSelect.prototype.fetchAll = function()
         cols.forEach(function(n,i) {
             var val = _this.get_value_at(i,r);
             var type = GObject.type_name(val.g_type) ;
-            var vs = type == 'GdaBlob' ? val.value.to_string(1024) : val.value;
-            print(n + " : TYPE: " + GObject.type_name(val.g_type) + " : " + vs);
+            var vs = ['GdaBinary', 'GdaBlob' ].indexOf(type) > -1 ? val.value.to_string(1024) : val.value;
+            //print(n + " : TYPE: " + GObject.type_name(val.g_type) + " : " + vs);
             //print (n + '=' + iter.get_value_at(i).value);
             add[n] = vs;
         });
@@ -139,17 +139,21 @@ if (File.isDirectory(cfg.INI)) {
 
     //--- load ini files..
     // this is very specific.
-    var dirs = File.list( GLib.get_home_dir() + '/gitlive').filter( 
-        function(e) { return e.match(/^Pman/); }
+    
+    var dirs = File.list( cfg.INI + '/Pman').filter( 
+        function(e) { 
+            if (!File.isDirectory(cfg.INI + '/Pman/' + e + '/DataObjects')) {
+                return false;
+            }
+            return true;
+        }
     );
     
+     
     dirs.forEach(function(d) {
         // this currently misses the web.*/Pman/XXXX/DataObjects..
-        var path = GLib.get_home_dir() + '/gitlive/' + d + '/DataObjects';
-        if (!File.isDirectory(path)) {
-            path = GLib.get_home_dir() + '/gitlive/' + d + '/Pman/DataObjects';
-        }
-        
+        var path = cfg.INI + '/Pman/' + d + '/DataObjects';
+         
         if (!File.isDirectory(path)) {
             return; //skip
         }
@@ -193,7 +197,7 @@ print(JSON.stringify(ini, null,4));
 var tables = Gda.execute_select_command(cnc, "SHOW TABLES").fetchAll();
 var readers = [];
 tables.forEach(function(table) {
-    print(table);
+    //print(table);
     var schema = Gda.execute_select_command(cnc, "DESCRIBE `" + table+'`').fetchAll();
     var reader = []; 
     var colmodel = []; 
@@ -398,7 +402,10 @@ readers.forEach(function(reader) {
         if (add.combofields.length < 2) {
             continue;
         }
-        
+        if (typeof(reader.form[col]) == 'undefined') {
+            print("missing linked column " + col);
+            continue;
+        }
         
         var combofields_name = add.combofields[1].name;
         var old =   reader.form[col];