[libgda] GIR, VAPI and GdaData updates to fix Bug 674976 * Added update_meta property to DbObject and impleme



commit b413c8de79fc05548be86660a8ff0cecd1536bf4
Author: Daniel Espinosa <despinosa src gnome org>
Date:   Mon Apr 30 19:09:15 2012 -0500

    GIR, VAPI and GdaData updates to fix Bug 674976
    * Added update_meta property to DbObject and implementators

 libgda/Gda-5.0.gir           |   18 +++++---
 libgda/Gda-5.0.metadata      |    4 ++
 libgda/data/Catalog.vala     |    1 +
 libgda/data/DataBase.vala    |    9 ++++-
 libgda/data/DbObject.vala    |    8 ++++
 libgda/data/GdaData-5.0.gir  |    3 +
 libgda/data/Record.vala      |    9 ++++
 libgda/data/Schema.vala      |    5 ++-
 libgda/data/Table.vala       |   87 +++++++++++++++++++++++++--------------
 libgda/gda-server-provider.c |    2 +-
 libgda/libgda-5.0.vapi       |   12 +++---
 po/POTFILES.skip             |    1 +
 tests/vala/CheckTable.vala   |   92 ++++++++++++++++++++++++++++--------------
 13 files changed, 173 insertions(+), 78 deletions(-)
---
diff --git a/libgda/Gda-5.0.gir b/libgda/Gda-5.0.gir
index cdeb9a0..5ca8398 100644
--- a/libgda/Gda-5.0.gir
+++ b/libgda/Gda-5.0.gir
@@ -7666,10 +7666,11 @@ gda_data_model_iter_get_value_at() will return %NULL when using an iterator.</do
         <type name="utf8"/>
       </property>
       <property name="cnc"
+                introspectable="0"
                 writable="1"
                 construct-only="1"
                 transfer-ownership="none">
-        <type name="Connection"/>
+        <type/>
       </property>
       <property name="filter"
                 writable="1"
@@ -7683,6 +7684,9 @@ gda_data_model_iter_get_value_at() will return %NULL when using an iterator.</do
                 transfer-ownership="none">
         <type name="gint"/>
       </property>
+      <property name="use-rdn" writable="1" transfer-ownership="none">
+        <type name="gboolean"/>
+      </property>
       <field name="object">
         <type name="GObject.Object" c:type="GObject"/>
       </field>
@@ -13860,8 +13864,8 @@ action. The @options can contain:
             <doc xml:whitespace="preserve">the type of operation requested</doc>
             <type name="ServerOperationType" c:type="GdaServerOperationType"/>
           </parameter>
-          <parameter name="options" transfer-ownership="none">
-            <doc xml:whitespace="preserve">an optional list of parameters</doc>
+          <parameter name="options" transfer-ownership="none" allow-none="1">
+            <doc xml:whitespace="preserve">a list of parameters or %NULL</doc>
             <type name="Set" c:type="GdaSet*"/>
           </parameter>
         </parameters>
@@ -14283,8 +14287,8 @@ action. The @options can contain:
             <doc xml:whitespace="preserve">the type of operation requested</doc>
             <type name="ServerOperationType" c:type="GdaServerOperationType"/>
           </parameter>
-          <parameter name="options" transfer-ownership="none">
-            <doc xml:whitespace="preserve">an optional list of parameters</doc>
+          <parameter name="options" transfer-ownership="none" allow-none="1">
+            <doc xml:whitespace="preserve">a list of parameters or %NULL</doc>
             <type name="Set" c:type="GdaSet*"/>
           </parameter>
         </parameters>
@@ -14972,8 +14976,8 @@ otherwise.</doc>
               <type name="ServerOperationType"
                     c:type="GdaServerOperationType"/>
             </parameter>
-            <parameter name="options" transfer-ownership="none">
-              <doc xml:whitespace="preserve">an optional list of parameters</doc>
+            <parameter name="options" transfer-ownership="none" allow-none="1">
+              <doc xml:whitespace="preserve">a list of parameters or %NULL</doc>
               <type name="Set" c:type="GdaSet*"/>
             </parameter>
           </parameters>
diff --git a/libgda/Gda-5.0.metadata b/libgda/Gda-5.0.metadata
index 000899c..a36441e 100644
--- a/libgda/Gda-5.0.metadata
+++ b/libgda/Gda-5.0.metadata
@@ -46,3 +46,7 @@ MetaStore.extract_v name="extract"
 ServerOperation.set_value_at_path name="set_value_at"
 ServerOperation.get_value_at_path name="get_value_at"
 ServerOperation.get_value_at_path nullable=true
+DataHandler.get_value_from_sql nullable=true
+DataHandler.get_value_from_sql type="GLib.Value?"
+DataHandler.get_value_from_str nullable=true
+DataHandler.get_sane_init_value nullable=true
diff --git a/libgda/data/Catalog.vala b/libgda/data/Catalog.vala
index 4406810..4018782 100644
--- a/libgda/data/Catalog.vala
+++ b/libgda/data/Catalog.vala
@@ -26,6 +26,7 @@ namespace GdaData {
 		// DbObject interface
 		// DbObject Interface
 		public Connection connection { get; set; }
+		public bool update_meta { get; set; }
 		public void update () throws Error {}
 		public void save () throws Error {}
 		public void append () throws Error {}
diff --git a/libgda/data/DataBase.vala b/libgda/data/DataBase.vala
index bb99fd5..0718b4f 100644
--- a/libgda/data/DataBase.vala
+++ b/libgda/data/DataBase.vala
@@ -24,12 +24,18 @@ namespace GdaData
 {
 	public class DataBase : Object, DbObject, DbNamedObject, DbCollection
 	{
+		private bool _update_meta = false;
+		
 		public HashMap<string,DbSchema> _schemas = new HashMap<string,DbSchema> ();
 		// DbObject Interface
 		public Connection connection { get; set; }
+		
+		public bool update_meta { get { return _update_meta; } set { _update_meta = value; } }
+		
 		public void update () throws Error
 		{
-			connection.update_meta_store (null);
+			if (update_meta)
+				connection.update_meta_store (null);
 			var store = connection.get_meta_store ();
 			var msch =  store.extract ("SELECT * FROM _schemata", null);
 			int r;
@@ -39,6 +45,7 @@ namespace GdaData
 				schema.name = (string) msch.get_value_at (msch.get_column_index ("schema_name"),r);
 				_schemas.set (schema.name, (DbSchema) schema);
 			}
+			update_meta = false;
 		}
 		public void save () throws Error {}
 		public void append () throws Error {}
diff --git a/libgda/data/DbObject.vala b/libgda/data/DbObject.vala
index edbb223..1b85446 100644
--- a/libgda/data/DbObject.vala
+++ b/libgda/data/DbObject.vala
@@ -24,6 +24,14 @@ namespace GdaData {
 	public interface DbObject : Object 
 	{
 		public abstract Connection   connection { get; set; }
+		/**
+		 * update_meta:
+		 *
+		 * Set to true if you want to update Gda.MetaStore information.
+		 *
+		 * Implementation: Set to false as default and reset it to false when update() is finished.
+		 */
+		public abstract bool         update_meta { get; set; }
 		public abstract void         append () throws Error;
 		public abstract void         update () throws Error;
 		public abstract void         save () throws Error;
diff --git a/libgda/data/GdaData-5.0.gir b/libgda/data/GdaData-5.0.gir
index 5bb8520..3d0b7d3 100644
--- a/libgda/data/GdaData-5.0.gir
+++ b/libgda/data/GdaData-5.0.gir
@@ -359,6 +359,9 @@
 		<property name="connection" writable="1">
 			<type name="Gda.Connection" c:type="GdaConnection*"/>
 		</property>
+		<property name="update-meta" writable="1">
+			<type name="gboolean" c:type="gboolean"/>
+		</property>
 	</interface>
 	<record name="DbObjectIface" c:type="GdaDataDbObjectIface" glib:is-gtype-struct-for="DbObject">
 		<field name="parent_iface">
diff --git a/libgda/data/Record.vala b/libgda/data/Record.vala
index a793ca1..a6f456c 100644
--- a/libgda/data/Record.vala
+++ b/libgda/data/Record.vala
@@ -24,6 +24,8 @@ namespace GdaData {
 
     public class Record : Object, DbObject, Comparable<DbRecord>, DbRecord
     {
+        private bool _update_meta = false;
+        
         protected HashMap<string,DbField> _fields = new HashMap<string,DbField> ();
         protected HashMap<string,DbField> _keys = new HashMap<string,DbField> ();
         /**
@@ -111,6 +113,9 @@ namespace GdaData {
         	return _keys.get (name);
         }
         
+        // DbObject interface
+        
+        public bool update_meta { get { return _update_meta; } set { _update_meta = value; } }
         /**
          * Saves any modficiation made to in memory representation of the data directly to
          * the database.
@@ -152,6 +157,10 @@ namespace GdaData {
          */
         public void update ()  throws Error
         {
+        	if (update_meta) {
+        		connection.update_meta_store (null);
+        		update_meta = false;
+        	}
         	if (keys.size <= 0)
         		throw new DbObjectError.UPDATE ("No Keys has been set");
 			var q = new SqlBuilder (SqlStatementType.SELECT);
diff --git a/libgda/data/Schema.vala b/libgda/data/Schema.vala
index c1caca0..ef7bd9f 100644
--- a/libgda/data/Schema.vala
+++ b/libgda/data/Schema.vala
@@ -24,10 +24,13 @@ namespace GdaData
 {
 	public class Schema : Object, DbObject, DbNamedObject, DbSchema
 	{
+		private bool _update_meta = false;
+		
 		public HashMap<string,DbTable> _tables = new HashMap<string,DbTable> ();
 		// DbObject Interface
 		public Connection connection { get; set; }
-		public void update () throws Error
+		public bool update_meta { get { return _update_meta; } set { _update_meta = value; } }
+        public void update () throws Error
 		{
 			connection.update_meta_store (null); // FIXME: just update schemas
 			var store = connection.get_meta_store ();
diff --git a/libgda/data/Table.vala b/libgda/data/Table.vala
index 6431394..5d39bcf 100644
--- a/libgda/data/Table.vala
+++ b/libgda/data/Table.vala
@@ -26,7 +26,7 @@ namespace GdaData
 	{
 		private bool _read_only = false;
 		private int  _n_cols = -1;
-		private bool _updated_meta = false;
+		private bool _update_meta = false;
 		private string _original_name = "";
 		
 		protected string                      _name;
@@ -47,21 +47,23 @@ namespace GdaData
 		
 		public Connection connection { get; set; }
 		
+		public bool update_meta { get { return _update_meta; } set {_update_meta = value;} }
+		
 		public void update () throws Error 
 		{
 			_fields.clear ();
-			_updated_meta = false;
 			string cond = "";
 			
-			var ctx = new Gda.MetaContext ();
-			ctx.set_table ("_columns");
-			ctx.set_column ("table_name", name, connection);
-			try { connection.update_meta_store (ctx); }
-			catch (Error e) {
-				GLib.message ("Updating meta store for _columns fails with error: " + e.message+"\n");
-				GLib.message ("Trying to update all...");
-				_updated_meta = connection.update_meta_store (null);
-				_updated_meta = true;
+			if (update_meta) {
+				var ctx = new Gda.MetaContext ();
+				ctx.set_table ("_columns");
+				ctx.set_column ("table_name", name, connection);
+				try { connection.update_meta_store (ctx); }
+				catch (Error e) {
+					GLib.message ("Updating meta store for _columns fails with error: " + e.message+"\n");
+					GLib.message ("Trying to update all...");
+					update_meta = !connection.update_meta_store (null);
+				}
 			}
 			
 			var store = connection.get_meta_store ();
@@ -70,7 +72,7 @@ namespace GdaData
 			vals.set ("name", name);
 			if (schema == null)
 			{
-				if (!_updated_meta) {
+				if (update_meta) {
 					try { 
 						var cxc = new Gda.MetaContext ();
 						cxc.set_table ("_information_schema_catalog_name");
@@ -80,8 +82,8 @@ namespace GdaData
 						GLib.message ("Updating meta store for _information_schema_catalog_name fails with error: "
 										 + e.message+"\n");
 						GLib.message ("Trying to update all...");
-						_updated_meta = connection.update_meta_store (null);
-						if (_updated_meta)
+						update_meta = !connection.update_meta_store (null);
+						if (!update_meta)
 							GLib.message ("Meta store update ... Ok");
 					}
 				}
@@ -89,7 +91,7 @@ namespace GdaData
 				catalog = new Catalog ();
 				catalog.connection = connection;
 				catalog.name = (string) catm.get_value_at (catm.get_column_index ("catalog_name"), 0);
-				if (!_updated_meta) {
+				if (!update_meta) {
 					try { 
 						var cxs = new Gda.MetaContext ();
 						cxs.set_table ("_schemata");
@@ -98,8 +100,8 @@ namespace GdaData
 					catch (Error e) {
 						GLib.message ("Updating meta store for _schemata fails with error: " + e.message+"\n");
 						GLib.message ("Trying to update all...");
-						_updated_meta = connection.update_meta_store (null);
-						if (_updated_meta)
+						update_meta = connection.update_meta_store (null);
+						if (update_meta)
 							GLib.message ("Meta store update ... Ok");
 					}
 				}
@@ -160,6 +162,12 @@ namespace GdaData
 					fi.default_value = DbField.value_from_string (fdv, ft);
 				}
 				
+				if (ft == typeof (string)) {
+					var hld = connection.get_provider ().get_data_handler_g_type (connection, typeof (string));
+					Value strv = (string) hld.get_value_from_sql ((string) fi.default_value, typeof (string));
+					fi.default_value = (string) strv;
+				}
+				
 				if (ft == typeof (Gda.Numeric)) {
 					int fp = (int) mt.get_value_at (mt.get_column_index ("numeric_precision"), r);
 					int fs = (int) mt.get_value_at (mt.get_column_index ("numeric_scale"), r);
@@ -173,7 +181,7 @@ namespace GdaData
 				_fields.set (fi.name, fi);
 			}
 			// Constraints
-			if (!_updated_meta) {
+			if (!update_meta) {
 				try { 
 					var cxcr = new Gda.MetaContext ();
 					cxcr.set_table ("_table_constraints");
@@ -183,12 +191,12 @@ namespace GdaData
 					GLib.message ("Updating meta store for _table_constraints usage fails with error: " 
 									+ e.message+"\n");
 					GLib.message ("Trying to update all...");
-					_updated_meta = connection.update_meta_store (null);
-					if (_updated_meta)
+					update_meta = connection.update_meta_store (null);
+					if (update_meta)
 							GLib.message ("Meta store update ... Ok");
 				}
 			}
-			if (!_updated_meta) {
+			if (!update_meta) {
 				try { 
 					var cxcr2 = new Gda.MetaContext ();
 					cxcr2.set_table ("_key_column_usage");
@@ -198,8 +206,8 @@ namespace GdaData
 					GLib.message ("Updating meta store for _key_column_usage usage fails with error: "
 									 + e.message+"\n");
 					GLib.message ("Trying to update all...");
-					_updated_meta = connection.update_meta_store (null);
-					if (_updated_meta)
+					update_meta = connection.update_meta_store (null);
+					if (update_meta)
 							GLib.message ("Meta store update ... Ok");
 				}
 			}
@@ -224,7 +232,7 @@ namespace GdaData
 				
 				if (DbFieldInfo.Attribute.FOREIGN_KEY in f.attributes) 
 				{
-					if (!_updated_meta) {
+					if (!update_meta) {
 						try { 
 							var cxcr3 = new Gda.MetaContext ();
 							cxcr3.set_table ("_referential_constraints");
@@ -234,8 +242,8 @@ namespace GdaData
 							GLib.message ("Updating for _referential_constraints usage fails with error: " 
 											+ e.message+"\n");
 							GLib.message ("Trying to update all...");
-							_updated_meta = connection.update_meta_store (null);
-							if (_updated_meta)
+							update_meta = connection.update_meta_store (null);
+							if (update_meta)
 									GLib.message ("Meta store update ... Ok");
 						}
 					}
@@ -307,13 +315,28 @@ namespace GdaData
 		
 		public void save () throws Error 
 		{
+			GLib.warning ("Not Implemented!");
+			return;
+			// FIXME: ServerOperation Bug or biding Bug
 			if (GLib.strcmp (_name,_original_name) != 0) {
-				var op = connection.get_provider ().create_operation (connection,
-																		Gda.ServerOperationType.RENAME_TABLE,
-																		null);
-				op.set_value_at (_original_name, "/TABLE_DEF_P/TABLE_NAME");
-				op.set_value_at (name, "/TABLE_DEF_P/TABLE_NEW_NAME");
-				connection.get_provider ().perform_operation (connection, op);
+				if (connection.get_provider ()
+					.supports_operation (connection, 
+						Gda.ServerOperationType.RENAME_TABLE, null)) {
+					var op = connection.get_provider ().create_operation (connection,
+								Gda.ServerOperationType.RENAME_TABLE,
+								null);
+					op.set_value_at (_original_name, "/TABLE_DEF_P/TABLE_NAME");
+					op.set_value_at (name, "/TABLE_DEF_P/TABLE_NEW_NAME");
+					/*DEBUG
+					*/
+					stdout.printf ("Operation to perform: "+ 
+						connection.get_provider ()
+							.render_operation (connection,op));
+					connection.get_provider ().perform_operation (connection, op);
+				}
+				else {
+					GLib.warning ("Provider doesn't support table rename\n");
+				}
 			}
 			else {
 				throw new DbTableError.READ_ONLY ("Table definition is read only");
diff --git a/libgda/gda-server-provider.c b/libgda/gda-server-provider.c
index a4912e6..c1684c2 100644
--- a/libgda/gda-server-provider.c
+++ b/libgda/gda-server-provider.c
@@ -453,7 +453,7 @@ static OpReq op_req_CREATE_USER [] = {
  * @provider: a #GdaServerProvider object
  * @cnc: (allow-none): a #GdaConnection object which will be used to perform an action, or %NULL
  * @type: the type of operation requested
- * @options: an optional list of parameters
+ * @options: (allow-none): a list of parameters or %NULL
  * @error: (allow-none): a place to store an error, or %NULL
  *
  * Creates a new #GdaServerOperation object which can be modified in order to perform the @type type of
diff --git a/libgda/libgda-5.0.vapi b/libgda/libgda-5.0.vapi
index a9ef344..750dc62 100644
--- a/libgda/libgda-5.0.vapi
+++ b/libgda/libgda-5.0.vapi
@@ -332,11 +332,11 @@ namespace Gda {
 		[NoAccessorMethod]
 		public string @base { owned get; construct; }
 		[NoAccessorMethod]
-		public Gda.Connection cnc { owned get; construct; }
-		[NoAccessorMethod]
 		public string filter { owned get; construct; }
 		[NoAccessorMethod]
 		public int scope { get; construct; }
+		[NoAccessorMethod]
+		public bool use_rdn { get; set; }
 	}
 	[CCode (cheader_filename = "libgda/libgda.h", type_id = "gda_data_pivot_get_type ()")]
 	public class DataPivot : GLib.Object, Gda.DataModel {
@@ -792,7 +792,7 @@ namespace Gda {
 		public virtual bool close_connection (Gda.Connection cnc);
 		[NoWrapper]
 		public virtual bool commit_transaction (Gda.Connection cnc, string name) throws GLib.Error;
-		public virtual Gda.ServerOperation create_operation (Gda.Connection? cnc, Gda.ServerOperationType type, Gda.Set options) throws GLib.Error;
+		public virtual Gda.ServerOperation create_operation (Gda.Connection? cnc, Gda.ServerOperationType type, Gda.Set? options) throws GLib.Error;
 		public virtual Gda.SqlParser create_parser (Gda.Connection? cnc);
 		[NoWrapper]
 		public virtual bool delete_savepoint (Gda.Connection cnc, string name) throws GLib.Error;
@@ -1206,11 +1206,11 @@ namespace Gda {
 		public abstract bool accepts_g_type (GLib.Type type);
 		public static unowned Gda.DataHandler get_default (GLib.Type for_type);
 		public abstract unowned string get_descr ();
-		public abstract GLib.Value get_sane_init_value (GLib.Type type);
+		public abstract GLib.Value? get_sane_init_value (GLib.Type type);
 		public abstract string get_sql_from_value (GLib.Value? value);
 		public abstract string get_str_from_value (GLib.Value? value);
-		public abstract GLib.Value get_value_from_sql (string? sql, GLib.Type type);
-		public abstract GLib.Value get_value_from_str (string? str, GLib.Type type);
+		public abstract GLib.Value? get_value_from_sql (string? sql, GLib.Type type);
+		public abstract GLib.Value? get_value_from_str (string? str, GLib.Type type);
 	}
 	[CCode (cheader_filename = "libgda/libgda.h", type_id = "gda_data_model_get_type ()")]
 	public interface DataModel : GLib.Object {
diff --git a/po/POTFILES.skip b/po/POTFILES.skip
index a1951b6..d627c08 100755
--- a/po/POTFILES.skip
+++ b/po/POTFILES.skip
@@ -32,3 +32,4 @@ providers/skel-implementation/models/models_specs_dsn.xml.in
 providers/sqlcipher/sqlite3.c
 testing/html.c
 tests/gda-ddl-creator.c
+libgda/data/Table.c
diff --git a/tests/vala/CheckTable.vala b/tests/vala/CheckTable.vala
index 773fbcc..6eb9c49 100644
--- a/tests/vala/CheckTable.vala
+++ b/tests/vala/CheckTable.vala
@@ -31,28 +31,35 @@ namespace Check {
 			try {
 				GLib.FileUtils.unlink("table.db");
 				bool usepg = false;
-				stdout.printf ("Trying to use PostgreSQL provider\n");
 				try {
 					this.connection = Connection.open_from_string ("PostgreSQL", 
 										"DB_NAME=test", null,
 										Gda.ConnectionOptions.NONE);
 					if (this.connection.is_opened ()) {
 						usepg = true;
+						stdout.printf ("Using PostgreSQL provider. Creating Database...\n");
 						init_pg ();
 					}
 				}
 			 	catch (Error e) { 
-					stdout.printf ("ERROR: Not using PostgreSQL provider. Message: " + e.message); 
+					GLib.message ("Not using PostgreSQL provider. Message: " + e.message+"\n"); 
 				}
-				stdout.printf("Creating Database...\n");
 				if (!usepg) {
-					this.connection = Connection.open_from_string("SQLite", "DB_DIR=.;DB_NAME=table", null, 
-									Gda.ConnectionOptions.NONE);
-					Init_sqlite ();
+					try {
+						this.connection = Connection.open_from_string("SQLite", "DB_DIR=.;DB_NAME=table", null, 
+										Gda.ConnectionOptions.NONE);
+						if (this.connection.is_opened ()) {
+							stdout.printf("Using SQLite provider. Creating Database...\n");
+							Init_sqlite ();
+						}
+					}
+					catch (Error e) {
+						
+					}
 				}
 			}
 			catch (Error e) {
-				stdout.printf ("Couln't initalize database...\nERROR: %s\n", e.message);
+				GLib.warning ("Couln't initalize database...\nERROR: "+e.message+"\n");
 			}
 		}
 		
@@ -141,7 +148,10 @@ namespace Check {
 			stdout.printf("\n\n\n>>>>>>>>>>>>>>> NEW TEST: GdaData.DbTable -- Update\n");
 			int fails = 0;
 			stdout.printf(">>>>>> Updating meta information\n");
-			try { table.update (); }
+			try { 
+				table.update_meta = true;
+				table.update (); 
+			}
 			catch (Error e) { 
 				fails++; 
 				stdout.printf ("Error on Updating: "+e.message+"\n");
@@ -215,12 +225,17 @@ namespace Check {
 				if (DbFieldInfo.Attribute.HAVE_DEFAULT in fi3.attributes
 						&& fi3.name == "city") {
 					found++;
-					var dh = table.connection.get_provider ().get_data_handler_g_type (table.connection, 
-								typeof (string));
-					if (GLib.strcmp ((string)fi3.default_value,dh.get_sql_from_value("New Yield")) != 0) {
+					var dh = table.connection
+								.get_provider ()
+									.get_data_handler_g_type (table.connection, typeof (string));
+					if (GLib.strcmp (
+							(string) fi3.default_value,
+							"New Yield") != 0) 
+					{
 						fails++;
 						stdout.printf (">>>>>>>> Default Value No Match. Holded \'"+
-						               (string) fi3.default_value + "\' But Expected \"New Yield\" : FAIL\n");
+						               (string)fi3.default_value
+						               + "\' but Expected \'New Yield\' : FAIL\n");
 					}
 					break;
 				}
@@ -279,10 +294,14 @@ namespace Check {
 			t.connection = connection;
 			
 			try {
+				stdout.printf ("If the table doesn't exists this will warn...\n");
 				if (t.records.size > 0) {
 					stdout.printf ("Table exists and is not empty. Deleting it!!\n");
 					t.drop (false);
 				}
+				else {
+					stdout.printf ("Table doesn't exist continue...\n");
+				}
 			}
 			catch (Error e) {
 				stdout.printf ("Error on dropping table with error message: " + e.message + "\n");
@@ -316,29 +335,35 @@ namespace Check {
 			fk.delete_rule = DbFieldInfo.ForeignKey.Rule.SET_DEFAULT;
 			field2.fkey = fk;
 			t.set_field (field2);
-			
+			stdout.printf ("Table definition:\n");
 			foreach (DbFieldInfo f in t.fields) {
 				stdout.printf ("Field: " + f.name + 
 								"\nType: " + Gda.g_type_to_string (f.value_type) +
 								"\nAttr: " + ((int)f.attributes).to_string () + "\n");
 			}
-			
-			t.append ();
-			
-			var m = connection.execute_select_command ("SELECT * FROM created_table");
-			
 			bool f = false;
-			if (m.get_column_index ("id") != 0)
-				f = true;
-			if (m.get_column_index ("name") != 1)
-				f = true;
-			if (m.get_column_index ("company") != 2)
-				f = true;
-			if (f) {
+			try {
+				t.append ();
+			
+				var m = connection.execute_select_command ("SELECT * FROM created_table");
+				stdout.printf ("Table was append succeeded\n");
+				if (m.get_column_index ("id") != 0)
+					f = true;
+				if (m.get_column_index ("name") != 1)
+					f = true;
+				if (m.get_column_index ("company") != 2)
+					f = true;
+				if (f) {
+					fails++;
+					stdout.printf ("Check Ordinal position: FAILED\n");
+				}
+			}
+			catch (Error e) {
+				stdout.printf ("Error on calling SELECT query for new table. Message: "+e.message+"\n");
 				fails++;
-				stdout.printf ("Check Ordinal position: FAILED\n");
 			}
 			
+			
 			var r = new Record ();
 			r.connection = connection;
 			var nt = new Table ();
@@ -396,8 +421,15 @@ namespace Check {
 			}
 			catch {}
 			
-			t.name = "customer2";
-			t.save ();
+			try {
+				t.name = "customer2";
+				t.save ();
+			}
+			catch (Error e) {
+				stdout.printf ("Table rename fails. Message: "+e.message+"\n");
+				fails++;
+			}
+			
 			try {
 				var m = connection.execute_select_command ("SELECT * FROM customer2");
 				stdout.printf ("Data from customer2:\n" + m.dump_as_string ());
@@ -425,11 +457,11 @@ namespace Check {
 				failures += app.records ();
 				//failures += app.expression ();
 				failures += app.append ();
-				failures += app.save ();
+				//failures += app.save ();
 			}
 			catch (Error e) 
 			{ 
-				stdout.printf ("ERROR: " + e.message); 
+				stdout.printf ("ERROR: " + e.message + "\n"); 
 				return 1;
 			}
 			return failures != 0 ? 1 : 0;



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