Index: trunk/prototype/api/datalayer.js
===================================================================
--- trunk/prototype/api/datalayer.js	(revision 5615)
+++ trunk/prototype/api/datalayer.js	(revision 5715)
@@ -136,4 +136,5 @@
     nestedLinks: {},
     concepts: {},
+    notArray: {},
     listeners: {},
     encoders: {},
@@ -388,10 +389,10 @@
 		    if( data[i][link] )
 		    {
-			var isConcept = false;
-		      
-			if( isConcept = this.isConcept( concept, link ) )
+			var notArray2 = false;
+
+			if( notArray2 = this.hasOne( concept, link ) )
 			    data[i][link] = [ data[i][link] ];
 
-			var _this = this;
+			var _this = this, dependency = this.isDependency( concept, link );
 
 			$.each( data[i][link], function( ii, el ){
@@ -404,5 +405,5 @@
 				//removido pois o mesmo esta gerando inconsistencia em tudo
 // 				if( DataLayer.isConcept( links[link], nestedLinks[link] ) )
-				if( isConcept )
+				if( !DataLayer.hasOne( links[link], nestedLinks[link] ) )
 				{
 				    el[ nestedLinks[link] ] = el[ nestedLinks[link] ] || [];
@@ -413,5 +414,5 @@
 
 				if( isRef && ( !current[ key ] || !current[ key ][ link ] || 
-				               (isConcept ? current[ key ][ link ] !== el.id : !$.inArray( el.id, current[ key ][ link ] )) ) )
+				               (notArray2 ? current[ key ][ link ] !== el.id : !$.inArray( el.id, current[ key ][ link ] )) ) )
 				{
 				    updateSet[ links[link] ] = updateSet[ links[link] ] || [];
@@ -422,5 +423,5 @@
 			    });
 
-			if( isConcept )
+			if( notArray2 )
 			    data[i][link] = data[i][link][0];
 		    }
@@ -489,5 +490,5 @@
 		    continue;
 
-		if( isConcept = this.isConcept( concept, link ) )
+		if( this.hasOne( concept, link ) )
 		    current[i][link] = [ current[i][link] ];
 
@@ -972,4 +973,6 @@
 
 	    this.links[ concept ] =  result['links'] || {};
+	    
+	    this.notArray[ concept ] = result['hasOne'] || {};
 
 	   this.nestedLinks[ concept ] = result['nestedLinks'] || {};
@@ -985,5 +988,5 @@
     },
     
-    isConcept: function( concept, attr ){
+    isDependency: function( concept, attr ){
       
 	if( typeof this.concepts[concept] === "undefined" )
@@ -993,4 +996,14 @@
 
 	return !!this.concepts[ concept ][ attr ];
+    },
+    
+    hasOne: function( concept, attr ){
+      
+	if( typeof this.notArray[concept] === "undefined" )
+	{
+	    this.links( concept );
+	}
+
+	return !!this.notArray[ concept ][ attr ];
     },
     
@@ -1112,5 +1125,5 @@
       
 	for( var key in base )
-	    if( this.storage.filter( base[key], this.copy( filter ) ) )
+	    if( this.storage.filter( base[key], filter ) )
 		filtered[ filtered.length ] = key;
 
@@ -1125,8 +1138,8 @@
 
     
-    compare: function( operator, b, t ){
+    compare: function( operator, base, test ){
       
-	var base = this.converterType(b);
-	var test = this.converterType(t);
+	base = this.converterType(base);
+	test = this.converterType(test);
 	 
     switch( operator ){
@@ -1145,5 +1158,5 @@
 	case '<':  return ( base >  test );
 	
-	default: return false;
+	default: return true;
 	}
       
@@ -1164,12 +1177,12 @@
 
 	if( !filter || !result )
-	  return DataLayer.copy( result || false );
-
-	var keys = [];
-
-	if( notArray = $.type(filter) === "string" )
-	    keys = [ filter ];
-	else if( $.type(filter) !== "array" )
-		keys = this.filter( result, filter.filter, filter.criteria );
+	  return( result || false );
+
+	var keys = DataLayer.copy( filter );
+
+	if( notArray = $.type(keys) === "string" )
+	    keys = [ keys ];
+	else if( $.type(keys) !== "array" )
+		keys = this.filter( result, keys.filter, keys.criteria );
 
 	var res = [];
@@ -1178,5 +1191,5 @@
 	    res[ res.length ] = result[keys[i]];
 
-	return DataLayer.copy( notArray ? res[0] || false : res.length ? res : false );
+	return( notArray ? res[0] || false : res.length ? res : false );
     },
 
@@ -1192,5 +1205,5 @@
 	get: function( key ){
 
-	    return this.cache[key];
+	    return DataLayer.copy( this.cache[key] );
 
 	},
