[libgda] Adding missing files and new API to DbRecord interface. Sample updates. * Added DbRecordCollection.v



commit 367ac00585ac1d888c44e797ecd9c597b1818176
Author: Daniel Espinosa <despinosa src gnome org>
Date:   Mon Jan 9 12:57:35 2012 -0600

    Adding missing files and new API to DbRecord interface. Sample updates.
    * Added DbRecordCollection.vala and RecordCollection.vala missing files
    * DbRecord and Record gains new set_field_value() and set_key_value() API
    * Sample Updated to latest API changes libgda/samples/vala/SampleDataObject.vala

 libgda/Gda-5.0.gir                     |   19 ---
 libgda/data/DbRecord.vala              |   20 ++--
 libgda/data/DbRecordCollection.vala    |   29 ++++
 libgda/data/GdaData-5.0.gir            |   88 ++++++++++++
 libgda/data/Record.vala                |   12 ++
 libgda/data/RecordCollection.vala      |  227 ++++++++++++++++++++++++++++++++
 libgda/libgda-5.0.vapi                 |    2 -
 samples/vala/SampleDataObject.vala     |   48 +++----
 tests/vala/CheckDataModelIterator.vala |    5 +-
 tests/vala/CheckDataObject.vala        |    4 +-
 10 files changed, 390 insertions(+), 64 deletions(-)
---
diff --git a/libgda/Gda-5.0.gir b/libgda/Gda-5.0.gir
index 7a745d1..b1de661 100644
--- a/libgda/Gda-5.0.gir
+++ b/libgda/Gda-5.0.gir
@@ -23439,25 +23439,6 @@ can also be used in hash tables as a #GEqualFunc.</doc>
         </parameter>
       </parameters>
     </function>
-    <function name="modify_statement_param_types"
-              c:identifier="gda_modify_statement_param_types"
-              version="5.2">
-      <doc xml:whitespace="preserve">Modifies the parameters in @stmt which will be mapped to columns in @model (using the +&amp;lt;colindex&amp;gt; or
--&amp;lt;colindex&amp;gt; syntax) to map the column types of @model.</doc>
-      <return-value transfer-ownership="none">
-        <type name="none" c:type="void"/>
-      </return-value>
-      <parameters>
-        <parameter name="stmt" transfer-ownership="none">
-          <doc xml:whitespace="preserve">a #GdaStatement</doc>
-          <type name="Statement" c:type="GdaStatement*"/>
-        </parameter>
-        <parameter name="model" transfer-ownership="none">
-          <doc xml:whitespace="preserve">a #GdaDataModel</doc>
-          <type name="DataModel" c:type="GdaDataModel*"/>
-        </parameter>
-      </parameters>
-    </function>
     <function name="mutex_new"
               c:identifier="gda_mutex_new"
               moved-to="Mutex.new"
diff --git a/libgda/data/DbRecord.vala b/libgda/data/DbRecord.vala
index c8ebafe..d847f70 100644
--- a/libgda/data/DbRecord.vala
+++ b/libgda/data/DbRecord.vala
@@ -24,17 +24,19 @@ namespace GdaData
 {
 	public interface DbRecord<G> : DbObject, Comparable<DbRecord<G>>
 	{
-		public abstract DbTable<G>                    table  { get; set construct; }
-		public abstract Collection<DbField<G>>        fields { owned get; }
-        public abstract Collection<DbField<G>>        keys   { owned get; }
+		public abstract DbTable<G>                table  { get; set construct; }
+		public abstract Collection<DbField<G>>    fields { owned get; }
+        public abstract Collection<DbField<G>>    keys   { owned get; }
         /**
          * Returns a GLib.Value containing the value stored in the given field.
          */
-        public abstract G                             get_value (string name) throws Error;
-        public abstract void                          set_field (DbField<G> field) throws Error;
-        public abstract DbField<G>                    get_field (string name) throws Error;
-        public abstract void                          set_key   (DbField<G> field) throws Error;
-        public abstract DbField<G>                    get_key   (string name) throws Error;
-        public abstract string                        to_string ();
+        public abstract G                         get_value        (string name) throws Error;
+        public abstract void                      set_field        (DbField<G> field) throws Error;
+        public abstract void                      set_field_value  (string field, G val) throws Error;
+        public abstract DbField<G>                get_field        (string name) throws Error;
+        public abstract void                      set_key          (DbField<G> field) throws Error;
+        public abstract void                      set_key_value    (string field, G val) throws Error;
+        public abstract DbField<G>                get_key          (string name) throws Error;
+        public abstract string                    to_string        ();
 	}
 }
diff --git a/libgda/data/DbRecordCollection.vala b/libgda/data/DbRecordCollection.vala
new file mode 100644
index 0000000..e07462c
--- /dev/null
+++ b/libgda/data/DbRecordCollection.vala
@@ -0,0 +1,29 @@
+	/* -*- Mode: Vala; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * libgdadata
+ * Copyright (C) Daniel Espinosa Ortiz 2011 <esodan gmail com>
+ * 
+ * libgda is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ * 
+ * libgda is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+ 
+using Gee;
+using Gda;
+
+namespace GdaData {
+	public interface DbRecordCollection<A,G> : Object, Traversable<G>, Iterable<G>, Collection<G>
+	{
+		public abstract Connection   connection { get; set; }
+		public abstract DbTable<A>   table      { get; }
+	}
+}
diff --git a/libgda/data/GdaData-5.0.gir b/libgda/data/GdaData-5.0.gir
index 12842a0..062dc58 100644
--- a/libgda/data/GdaData-5.0.gir
+++ b/libgda/data/GdaData-5.0.gir
@@ -476,6 +476,32 @@
 				<type name="none"/>
 			</return-value>
 		</virtual-method>
+		<method name="set_field_value" c:identifier="gda_data_db_record_set_field_value" throws="1">
+			<parameters>
+				<parameter name="field" transfer-ownership="none">
+					<type name="utf8" c:type="const gchar*"/>
+				</parameter>
+				<parameter name="val" transfer-ownership="none" allow-none="1">
+					<type name="gpointer" c:type="gpointer"/>
+				</parameter>
+			</parameters>
+			<return-value transfer-ownership="full">
+				<type name="none"/>
+			</return-value>
+		</method>
+		<virtual-method name="set_field_value" invoker="set_field_value" throws="1">
+			<parameters>
+				<parameter name="field" transfer-ownership="none">
+					<type name="utf8" c:type="const gchar*"/>
+				</parameter>
+				<parameter name="val" transfer-ownership="none" allow-none="1">
+					<type name="gpointer" c:type="gpointer"/>
+				</parameter>
+			</parameters>
+			<return-value transfer-ownership="full">
+				<type name="none"/>
+			</return-value>
+		</virtual-method>
 		<method name="get_field" c:identifier="gda_data_db_record_get_field" throws="1">
 			<parameters>
 				<parameter name="name" transfer-ownership="none">
@@ -524,6 +550,32 @@
 				<type name="none"/>
 			</return-value>
 		</virtual-method>
+		<method name="set_key_value" c:identifier="gda_data_db_record_set_key_value" throws="1">
+			<parameters>
+				<parameter name="field" transfer-ownership="none">
+					<type name="utf8" c:type="const gchar*"/>
+				</parameter>
+				<parameter name="val" transfer-ownership="none" allow-none="1">
+					<type name="gpointer" c:type="gpointer"/>
+				</parameter>
+			</parameters>
+			<return-value transfer-ownership="full">
+				<type name="none"/>
+			</return-value>
+		</method>
+		<virtual-method name="set_key_value" invoker="set_key_value" throws="1">
+			<parameters>
+				<parameter name="field" transfer-ownership="none">
+					<type name="utf8" c:type="const gchar*"/>
+				</parameter>
+				<parameter name="val" transfer-ownership="none" allow-none="1">
+					<type name="gpointer" c:type="gpointer"/>
+				</parameter>
+			</parameters>
+			<return-value transfer-ownership="full">
+				<type name="none"/>
+			</return-value>
+		</virtual-method>
 		<method name="get_key" c:identifier="gda_data_db_record_get_key" throws="1">
 			<parameters>
 				<parameter name="name" transfer-ownership="none">
@@ -614,6 +666,24 @@
 				</return-value>
 			</callback>
 		</field>
+		<field name="set_field_value">
+			<callback name="set_field_value" c:type="set_field_value" throws="1">
+				<parameters>
+					<parameter name="self" transfer-ownership="none">
+						<type name="GdaData.DbRecord" c:type="GdaDataDbRecord*"/>
+					</parameter>
+					<parameter name="field" transfer-ownership="none">
+						<type name="utf8" c:type="const gchar*"/>
+					</parameter>
+					<parameter name="val" transfer-ownership="none" allow-none="1">
+						<type name="gpointer" c:type="gpointer"/>
+					</parameter>
+				</parameters>
+				<return-value transfer-ownership="full">
+					<type name="none"/>
+				</return-value>
+			</callback>
+		</field>
 		<field name="get_field">
 			<callback name="get_field" c:type="get_field" throws="1">
 				<parameters>
@@ -648,6 +718,24 @@
 				</return-value>
 			</callback>
 		</field>
+		<field name="set_key_value">
+			<callback name="set_key_value" c:type="set_key_value" throws="1">
+				<parameters>
+					<parameter name="self" transfer-ownership="none">
+						<type name="GdaData.DbRecord" c:type="GdaDataDbRecord*"/>
+					</parameter>
+					<parameter name="field" transfer-ownership="none">
+						<type name="utf8" c:type="const gchar*"/>
+					</parameter>
+					<parameter name="val" transfer-ownership="none" allow-none="1">
+						<type name="gpointer" c:type="gpointer"/>
+					</parameter>
+				</parameters>
+				<return-value transfer-ownership="full">
+					<type name="none"/>
+				</return-value>
+			</callback>
+		</field>
 		<field name="get_key">
 			<callback name="get_key" c:type="get_key" throws="1">
 				<parameters>
diff --git a/libgda/data/Record.vala b/libgda/data/Record.vala
index bffbc84..35c9513 100644
--- a/libgda/data/Record.vala
+++ b/libgda/data/Record.vala
@@ -66,6 +66,12 @@ namespace GdaData {
         	}
         	
         }
+        public void set_field_value (string field, Value? val) throws Error
+        {
+        	var n = new Field<Value?> (field, DbField.Attribute.NONE); 
+    		n.value = val;
+    		this.set_field (n);
+        }
         public DbField<Value?> get_field (string name) throws Error
         {
         	return _fields.get (name);
@@ -84,6 +90,12 @@ namespace GdaData {
         		_keys.set (field.name, n);
         	}
         }
+        public void set_key_value (string key, Value? val) throws Error
+        {
+        	var n = new Field<Value?> (key, DbField.Attribute.NONE); 
+    		n.value = val;
+    		this.set_key (n);
+        }
         public DbField<Value?> get_key (string name) throws Error
         {
         	return _keys.get (name);
diff --git a/libgda/data/RecordCollection.vala b/libgda/data/RecordCollection.vala
new file mode 100644
index 0000000..465511e
--- /dev/null
+++ b/libgda/data/RecordCollection.vala
@@ -0,0 +1,227 @@
+/* -*- Mode: Vala; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * libgdadata
+ * Copyright (C) Daniel Espinosa Ortiz 2011 <esodan gmail com>
+ * 
+ * libgda is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ * 
+ * libgda is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+ 
+using Gee;
+using Gda;
+
+namespace GdaData {
+	public class RecordCollection : AbstractCollection<DbRecord<Value?>>, 
+	DbRecordCollection<Value?,DbRecord<Value?>>
+	{
+		private DataModel _model;
+		private DbTable _table;
+		
+		public DbTable<Value?> table { get { return table; } }
+		
+		public DataModel model { get { return _model; } }
+		
+		public Connection connection { get; set; }
+		
+		public RecordCollection (DataModel m, DbTable table)
+		{
+			((DataSelect) m).compute_modification_statements ();
+			var pm = DataProxy.new (m);
+			_model = (DataModel) pm;
+			_table = table;
+		}
+		// AbstractCollection Implementation
+		public override bool add (DbRecord<Value?> item) 
+		{ 
+			try {
+				int r = _model.append_row ();
+				foreach (DbField<Value?> f in item.fields) {
+					_model.set_value_at (_model.get_column_index (f.name), r, f.value);
+				}
+				return true;
+			} catch {}
+			return false; 
+		}
+		public override void clear ()
+		{ 
+			var iter = _model.create_iter ();
+			while (iter.move_next ()) {
+				_model.remove_row (iter.get_row ());
+			}
+			((DataProxy) _model).apply_all_changes ();
+		}
+		public override bool contains (DbRecord<Value?> item)
+		{
+			var iter = _model.create_iter ();
+			while (iter.move_next ()) {
+				bool found = true;
+				foreach (DbField<Value?> k in item.keys) {
+					Value id = iter.get_value_at (iter.data_model.get_column_index (k.name));
+					Value v = k.value;
+					if (Gda.value_compare (id,v) != 0)
+						found = false;
+				}
+				if (found) return true;
+			}
+			return false;
+		}
+		public override Gee.Iterator<DbRecord<Value?>> iterator () 
+		{ 
+			var iter = _model.create_iter ();
+			return new RecordCollectionIterator (iter, table); 
+		}
+		public override bool remove (DbRecord<Value?> item)
+		{
+			var iter = _model.create_iter ();
+			while (iter.move_next ()) {
+				bool found = true;
+				foreach (DbField<Value?> k in item.keys) {
+					Value id = iter.get_value_at (iter.data_model.get_column_index (k.name));
+					Value v = k.value;
+					if (Gda.value_compare (id,v) != 0)
+						found = false;
+				}
+				if (found) {
+					try {
+						_model.remove_row (iter.get_row ());
+						((DataProxy)_model).apply_all_changes ();
+						return true;
+					} catch {}
+				}
+			}
+			return false;
+		}
+		public override bool read_only { 
+			get {
+				var f = _model.get_access_flags ();
+				if ( (f & Gda.DataModelAccessFlags.INSERT
+					& Gda.DataModelAccessFlags.UPDATE
+					& Gda.DataModelAccessFlags.DELETE) != 0 )
+					return true;
+				else
+					return false;
+			}
+		}
+		public override int size { 
+			get {
+				return _model.get_n_rows ();
+			} 
+		}
+		// 
+		public string to_string ()
+		{
+			return _model.dump_as_string ();
+		}
+	}
+	
+	public class RecordCollectionIterator : Object, Traversable<DbRecord<Value?>>, Iterator<DbRecord<Value?>>
+	{
+		private DataModelIter _iter;
+		private DbTable _table;
+		private int _length = -1;
+		private HashMap<int,int> _elements = new HashMap<int,int>();
+		
+		public RecordCollectionIterator (DataModelIter iter, DbTable table)
+		{
+			_iter = iter;
+			_table = table;
+			_length = _iter.data_model.get_n_rows ();
+		}
+		
+		private RecordCollectionIterator.filtered_elements (DataModelIter iter, DbTable table, HashMap<int,int> elements)
+		{
+			_iter = iter;
+			_table = table;
+			_elements = elements;
+		}
+		private RecordCollectionIterator.with_lenght (DataModelIter iter, DbTable table, int length)
+		{
+			_iter = iter;
+			_table = table;
+			if (length >= 0 && _iter.is_valid ())
+				_length = _iter.current_row + length;
+			if (_length > _iter.data_model.get_n_rows ())
+				_length = _iter.data_model.get_n_rows ();
+		}
+		
+		// Traversable Interface
+		public Gee.Iterator<DbRecord<Value?>> chop (int offset, int length = -1) 
+		{
+			var iter = _iter.data_model.create_iter ();
+			iter.move_to_row (offset);
+			return new RecordCollectionIterator.with_lenght (iter, _table, length);
+		}
+		public Gee.Iterator<DbRecord<Value?>> filter (owned Gee.Predicate<DbRecord<Value?>> f) 
+		{
+			var elements = new Gee.HashMap <int,int> ();
+			while (_iter.move_next ()) {
+				var r = this.get ();
+				if (f(r)) {
+					elements.set (_iter.get_row (), _iter.get_row ());
+				}
+			}
+			var iter = _iter.data_model.create_iter ();
+			return (Iterator<DbRecord<Value?>>) new RecordCollectionIterator.filtered_elements (iter, _table, elements);
+		}
+		public new void @foreach (Gee.ForallFunc<DbRecord<Value?>> f) 
+		{
+			while (_iter.move_next ()) {
+				var r = this.get ();
+				f(r);
+			}
+		}
+		public Gee.Iterator<A> stream<A> (owned Gee.StreamFunc<DbRecord<Value?>,A> f) 
+		{
+			return Gee.Iterator<A>.stream_impl<DbRecord<Value?>,A> (this, f);
+		}
+		
+		// Iterator Interface
+		public new DbRecord<Value?> @get ()
+		{
+			var r = new Record ();
+			r.connection = _table.connection;
+			r.table = _table;
+			for (int c = 0; c < _iter.data_model.get_n_columns (); c++) {
+				// FIXME: get attributes from table
+				var f = new Field<Value?>(_iter.data_model.get_column_name (c), DbField.Attribute.NONE);
+				f.value = _iter.get_value_at (c);
+				r.set_field (f);
+			}
+			return (DbRecord<Value?>) r;
+		}
+		public bool has_next () 
+		{
+			return _iter.current_row + 1 <= _iter.data_model.get_n_rows () ? true : false;
+		}
+		public bool next () 
+		{ 
+			var r = _iter.move_next ();
+			if (_iter.current_row > _length) {
+				_iter.invalidate_contents ();
+				return false;
+			}
+			return r;
+		}
+		public void remove () { _iter.data_model.remove_row (_iter.current_row); }
+		public bool read_only 
+		{ 
+			get { 
+				if (_iter.data_model is DataProxy)
+					return ((DataProxy)_iter.data_model).is_read_only ();
+				else
+					return false;
+			}
+		}
+		public bool valid { get { return _iter.is_valid (); } }
+	}
+}
diff --git a/libgda/libgda-5.0.vapi b/libgda/libgda-5.0.vapi
index 65049ad..82d47ac 100644
--- a/libgda/libgda-5.0.vapi
+++ b/libgda/libgda-5.0.vapi
@@ -2031,8 +2031,6 @@ namespace Gda {
 	[CCode (cheader_filename = "libgda/libgda.h")]
 	public static bool log_is_enabled ();
 	[CCode (cheader_filename = "libgda/libgda.h")]
-	public static void modify_statement_param_types (Gda.Statement stmt, Gda.DataModel model);
-	[CCode (cheader_filename = "libgda/libgda.h")]
 	public static bool parse_iso8601_date (GLib.Date gdate, string value);
 	[CCode (cheader_filename = "libgda/libgda.h")]
 	public static bool parse_iso8601_time (Gda.Time timegda, string value);
diff --git a/samples/vala/SampleDataObject.vala b/samples/vala/SampleDataObject.vala
index 44ef96f..65a7756 100644
--- a/samples/vala/SampleDataObject.vala
+++ b/samples/vala/SampleDataObject.vala
@@ -22,27 +22,7 @@ using GdaData;
 
 namespace Sample {
 
-	class Record : RecordSingleId {
-		private static string dbtable = "user";
-		
-		/**
-		 * On derived classes you must implement this property.
-		 * Is intended that implementors set table and don't change it in the object live time
-		 * in order to keep a good reference to the data the object refers to.
-		 */
-		public override string table { 
-			get { return this.dbtable; }
-		}
-		/**
-		 * On derived classes you must implement this property.
-		 * Is intended that implementors set ID field's name and its column index
-		 */
-		public override string field_id {
-			get { return "name";}
-		}
-		public override int field_id_index {
-			get { return 0; }
-		}
+	class Record : GdaData.Record {
 		/**
 		 * Wrapping database fields.
 		 * You can define properties that use database stored values.
@@ -56,7 +36,7 @@ namespace Sample {
 			}
 			set {
 				try {
-					this.set_value ("functions", value);
+					this.set_field_value ("functions", value);
 				}
 				catch {}
 			}
@@ -69,11 +49,22 @@ namespace Sample {
 			
 			set {
 				try {
-					this.set_value ("name", value);
+					this.set_field_value ("name", value);
 				}
 				catch {}
 			}
 		}
+		
+		/**
+		 * This will create a default table to 'user'.
+		 */
+		public Record ()
+		{
+			var t = new Table<Value?> ();
+			t.name = "user";
+			t.connection = this.connection;
+			this.table = t;
+		}
 	}
 
 	class App : Object {
@@ -89,7 +80,7 @@ namespace Sample {
 								Gda.ConnectionOptions.NONE);
 			stdout.printf("Creating table 'user'...\n");
 			this.connection.execute_non_select_command("CREATE TABLE user (name string PRIMARY KEY, functions string, security_number integer)");
-			this.connection.execute_non_select_command("INSERT INTO user (name, functions, security_number) VALUES (\"Martin Stewart\", \"Programmer, QA\", 2334556)");
+			this.connection.execute_non_select_command("INSERT INTO user (name, functions, security_number) VALUES ( \"Martin Stewart\", \"Programmer, QA\", 2334556)");
 			this.connection.execute_non_select_command("INSERT INTO user (name, functions, security_number) VALUES (\"Jane Castle\", \"Accountant\", 3002884)");
 			
 			this.connection.update_meta_store(null);
@@ -101,7 +92,10 @@ namespace Sample {
 			stdout.printf (">>> DEMO: Modifying Records\n");
 			var rcd = new Sample.Record ();
 			rcd.connection = this.connection;
-			try { rcd.set_id (name); }
+			try { 
+				rcd.set_key_value ("name", name);
+				rcd.update ();
+			}
 			catch (Error e) { stdout.printf ("ERROR: Record no opened\n" + e.message + "\n"); }
 			
 			stdout.printf ("Initial Values for: " + rcd.name + "\n" + rcd.to_string () + "\n");
@@ -117,7 +111,7 @@ namespace Sample {
 			// You must know the field name refer to
 			var v = rcd.get_value ("security_number");
 			stdout.printf ("Initial value for field 'security_number' in the DB: " + Gda.value_stringify (v) + "\n");
-			rcd.set_value ("security_number", 1002335);
+			rcd.set_field_value ("security_number", 1002335);
 			
 			try { rcd.save (); }
 			catch (Error e) { stdout.printf ("ERROR: Can't save modifycations'\n" + e.message + "\n"); }
@@ -130,7 +124,7 @@ namespace Sample {
 			stdout.printf (">>> DEMO: Updating Records modified externally\n");
 			var rcd = new Record ();
 			rcd.connection = this.connection;
-			rcd.set_id ("Jane Castle PhD.");
+			rcd.set_key_value ("name", "Jane Castle PhD.");
 			stdout.printf ("Initial Values for: " + rcd.name + "\n" + rcd.to_string () + "\n");
 			this.connection.execute_non_select_command("UPDATE user SET functions = \"Secretary\" WHERE name = \"Jane Castle PhD.\"");
 			rcd.update ();
diff --git a/tests/vala/CheckDataModelIterator.vala b/tests/vala/CheckDataModelIterator.vala
index d123a93..adaf0cd 100644
--- a/tests/vala/CheckDataModelIterator.vala
+++ b/tests/vala/CheckDataModelIterator.vala
@@ -58,10 +58,7 @@ namespace Check {
 			t.connection = this.connection;
 			t.name = "user";
 			var itermodel = new RecordCollection (model, t);
-			var iter = itermodel.iterator ();
-			var iter.next ();
-			var r = iter.get ();
-			stdout.printf ("First Record contents: \n" + r.to_string ());
+//			stdout.printf ("First Record contents: \n" + r.to_string ());
 			stdout.printf ("Iterating over all Records in DataModel\n");
 			foreach (DbRecord<Value?> r in itermodel) {
 				stdout.printf (r.to_string ());
diff --git a/tests/vala/CheckDataObject.vala b/tests/vala/CheckDataObject.vala
index e989cac..7cc5d60 100644
--- a/tests/vala/CheckDataObject.vala
+++ b/tests/vala/CheckDataObject.vala
@@ -214,9 +214,7 @@ namespace Check {
 				f.set ("name", "GdaDataNewName");
 				f.set ("city","GdaDataNewCity");
 				foreach (string k in f.keys) {
-					var field = new Field<Value?>(k, DbField.Attribute.NONE);
-					field.value = f.get (k);
-					n.set_field (field);
+					n.set_field_value (k, f.get (k));
 				}
 				stdout.printf("DbRecord in memory values, to added to table '%s':\n", n.table.name);
 				stdout.printf("%s\n", n.to_string());



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