[libgda] GdaData.Table pass Unit Test for records * Table.records changed to DbRecordCollection



commit cdb27a011fcf7c6b9d85514706ea19bbbee3b94f
Author: Daniel Espinosa <despinosa src gnome org>
Date:   Tue Feb 21 07:20:50 2012 -0600

    GdaData.Table pass Unit Test for records
    * Table.records changed to DbRecordCollection

 libgda/data/DbTable.vala    |   16 ++++++++--------
 libgda/data/GdaData-5.0.gir |    4 +---
 libgda/data/Table.vala      |    5 +++--
 tests/vala/CheckTable.vala  |   25 ++++++++++++++++++++-----
 4 files changed, 32 insertions(+), 18 deletions(-)
---
diff --git a/libgda/data/DbTable.vala b/libgda/data/DbTable.vala
index 689f895..59b4589 100644
--- a/libgda/data/DbTable.vala
+++ b/libgda/data/DbTable.vala
@@ -24,14 +24,14 @@ namespace GdaData
 {
 	public interface DbTable : Object, DbObject, DbNamedObject
 	{
-		public abstract DbCatalog                        catalog       { get; set; }
-		public abstract DbSchema                         schema        { get; set; }
-		public abstract TableType                        table_type    { get; set; }
-		public abstract Collection<DbRecord>             records       { owned get; }
-		public abstract Collection<DbTable>              depends       { owned get; }
-		public abstract Collection<DbTable>              referenced    { owned get; }
-		public abstract Collection<DbFieldInfo>          fields        { owned get; }
-		public abstract Collection<DbFieldInfo>          primary_keys  { owned get; }
+		public abstract DbCatalog                   catalog       { get; set; }
+		public abstract DbSchema                    schema        { get; set; }
+		public abstract TableType                   table_type    { get; set; }
+		public abstract DbRecordCollection          records       { owned get; }
+		public abstract Collection<DbTable>         depends       { owned get; }
+		public abstract Collection<DbTable>         referenced    { owned get; }
+		public abstract Collection<DbFieldInfo>     fields        { owned get; }
+		public abstract Collection<DbFieldInfo>     primary_keys  { owned get; }
 		
 		public enum TableType {
 			NONE,
diff --git a/libgda/data/GdaData-5.0.gir b/libgda/data/GdaData-5.0.gir
index e07221e..d30a21c 100644
--- a/libgda/data/GdaData-5.0.gir
+++ b/libgda/data/GdaData-5.0.gir
@@ -440,9 +440,7 @@
 			<type name="GdaData.DbTableTableType" c:type="GdaDataDbTableTableType"/>
 		</property>
 		<property name="records">
-			<type name="Gee.Collection" c:type="GeeCollection*">
-				<type name="GdaData.DbRecord" c:type="GdaDataDbRecord*"/>
-			</type>
+			<type name="GdaData.DbRecordCollection" c:type="GdaDataDbRecordCollection*"/>
 		</property>
 		<property name="depends">
 			<type name="Gee.Collection" c:type="GeeCollection*">
diff --git a/libgda/data/Table.vala b/libgda/data/Table.vala
index 1cf3852..9afced6 100644
--- a/libgda/data/Table.vala
+++ b/libgda/data/Table.vala
@@ -220,15 +220,16 @@ namespace GdaData
 				return  pk.values;
 			} 
 		}
+		
 		public DbCatalog catalog { get; set; }
 		
 		public DbSchema  schema { get; set; }
 		
-		public Collection<DbRecord> records { 
+		public DbRecordCollection records { 
 			owned get  {
 				try {
 					var q = new Gda.SqlBuilder (SqlStatementType.SELECT);
-					q.set_table (name);
+					q.select_add_target (name, null);
 					q.select_add_field ("*", null, null);
 					var s = q.get_statement ();
 					var m = this.connection.statement_execute_select (s, null);
diff --git a/tests/vala/CheckTable.vala b/tests/vala/CheckTable.vala
index 73ef32c..e04f846 100644
--- a/tests/vala/CheckTable.vala
+++ b/tests/vala/CheckTable.vala
@@ -42,7 +42,7 @@ namespace Check {
 				                                           " city string DEFAULT \"New Yield\","+
 				                                           " company integer REFERENCES company (id) ON DELETE SET NULL ON UPDATE CASCADE)");
 				this.connection.execute_non_select_command("INSERT INTO customer (id, name, city, company) VALUES (1, \"Daniel\", \"Mexico\", 1)");
-				this.connection.execute_non_select_command("INSERT INTO customer (id, name, city) VALUES (2, \"Jhon\", \"USA\")");
+				this.connection.execute_non_select_command("INSERT INTO customer (id, name, city) VALUES (2, \"Jhon\", \"Springfield\")");
 				this.connection.execute_non_select_command("INSERT INTO customer (id, name) VALUES (3, \"Jack\")");
 				stdout.printf("Creating table 'salary'...\n");
 				this.connection.execute_non_select_command("CREATE TABLE salary (id integer PRIMARY KEY AUTOINCREMENT,"+
@@ -162,6 +162,21 @@ namespace Check {
 				stdout.printf (">>>>>>>> TEST PASS <<<<<<<<<<<\n");
 			return fails;
 		}
+
+		public int records ()
+			throws Error
+		{
+			stdout.printf("\n\n\n>>>>>>>>>>>>>>> NEW TEST: Gda.DbTable - Records...\n");
+			int fails = 0;
+			foreach (DbRecord r in table.records) {
+				stdout.printf (r.to_string () + "\n");
+			}
+			if (fails > 0)
+				stdout.printf (">>>>>>>> FAIL <<<<<<<<<<<\n");
+			else
+				stdout.printf (">>>>>>>> TEST PASS <<<<<<<<<<<\n");
+			return fails;
+		}
 		
 		public static int main (string[] args) {
 			stdout.printf ("\n\n\n>>>>>>>>>>>>>>>> NEW TEST: Checking GdaData.DbRecord implementation... <<<<<<<<<< \n");
@@ -171,10 +186,10 @@ namespace Check {
 				app.init ();
 				failures += app.update ();
 				failures += app.fields ();
-				//failures += app.records ();
-				//failures += app.depends ();
-				//failures += app.references ();
-				//failures += app.check_expression ();
+				failures += app.records ();
+				//failures += app.expression ();
+				//failures += app.append ();
+				//failures += app.save ();
 			}
 			catch (Error e) 
 			{ 



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