[libgda] Fix binding for GdaServerOperation.get_value_at_path. GdaData.Table.save () update. * Fixed Vala bin



commit 48beddf13f69e07f428b94a286daf46d22cdd8d1
Author: Daniel Espinosa <despinosa src gnome org>
Date:   Thu Mar 1 22:02:23 2012 -0600

    Fix binding for GdaServerOperation.get_value_at_path. GdaData.Table.save () update.
    * Fixed Vala binding for GdaServerOperation.get_value_at_path renamed to get_value_at
    * GdaData.Table.save () tries to rename table but theres a problem with
    Gda.ServerOperation.set_value_at () working on

 configure.ac                  |    2 +-
 libgda/Gda-5.0.gir            |    3 +++
 libgda/Gda-5.0.metadata       |    2 ++
 libgda/data/GdaData-5.0.gir   |    3 +++
 libgda/data/Table.vala        |   26 ++++++++++++++++++++++++--
 libgda/gda-server-operation.c |    2 +-
 libgda/libgda-5.0.vapi        |    5 ++++-
 tests/vala/CheckTable.vala    |   36 +++++++++++++++++++++++++++++++++++-
 8 files changed, 73 insertions(+), 6 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 6ff1d1b..187b229 100644
--- a/configure.ac
+++ b/configure.ac
@@ -481,7 +481,7 @@ AC_ARG_ENABLE([vala-extensions],
 have_vala=no
 if test "x$found_introspection" = "xyes"
 then
-    VALA_MODULES="libvala-0.16 >= 0.15.1"
+    VALA_MODULES="libvala-0.16 >= 0.15.0"
     PKG_CHECK_MODULES(VALA, $VALA_MODULES,
     if test "$enable_vala" = "yes" -o "$enable_vala" = "auto"
 	then
diff --git a/libgda/Gda-5.0.gir b/libgda/Gda-5.0.gir
index 52a11af..19fde7d 100644
--- a/libgda/Gda-5.0.gir
+++ b/libgda/Gda-5.0.gir
@@ -7666,6 +7666,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>
diff --git a/libgda/Gda-5.0.metadata b/libgda/Gda-5.0.metadata
index a9cb119..000899c 100644
--- a/libgda/Gda-5.0.metadata
+++ b/libgda/Gda-5.0.metadata
@@ -44,3 +44,5 @@ Row.get_value nullable=true
 Numeric.get_string nullable=true
 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
diff --git a/libgda/data/GdaData-5.0.gir b/libgda/data/GdaData-5.0.gir
index f2b07b9..c520a00 100644
--- a/libgda/data/GdaData-5.0.gir
+++ b/libgda/data/GdaData-5.0.gir
@@ -105,6 +105,9 @@
 		<field name="priv">
 			<type name="TablePrivate" c:type="GdaDataTablePrivate*"/>
 		</field>
+		<field name="_name">
+			<type name="utf8" c:type="gchar*"/>
+		</field>
 		<field name="_type">
 			<type name="GdaData.DbTableTableType" c:type="GdaDataDbTableTableType"/>
 		</field>
diff --git a/libgda/data/Table.vala b/libgda/data/Table.vala
index 2ee31a3..6431394 100644
--- a/libgda/data/Table.vala
+++ b/libgda/data/Table.vala
@@ -27,7 +27,9 @@ namespace GdaData
 		private bool _read_only = false;
 		private int  _n_cols = -1;
 		private bool _updated_meta = false;
+		private string _original_name = "";
 		
+		protected string                      _name;
 		protected DbTable.TableType           _type;
 		protected DbRecordCollection          _records;
 		protected HashMap<string,DbFieldInfo> _fields = new HashMap<string,DbFieldInfo> ();
@@ -305,7 +307,17 @@ namespace GdaData
 		
 		public void save () throws Error 
 		{
-			throw new DbTableError.READ_ONLY ("Table's definition is read only");
+			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);
+			}
+			else {
+				throw new DbTableError.READ_ONLY ("Table definition is read only");
+			}
 		}
 		
 		public void append () throws Error 
@@ -365,7 +377,17 @@ namespace GdaData
 		
 		// DbNamedObject Interface
 		
-		public string name { get; set; }
+		public string name 
+		{ 
+			get { return _name; }
+			set 
+			{
+				if (GLib.strcmp ("",_original_name) == 0) {
+					_original_name = value;
+				}
+				_name = value;
+			}
+		}
 		
 		// DbTable Interface
 		
diff --git a/libgda/gda-server-operation.c b/libgda/gda-server-operation.c
index 1a0fe1d..f8c5e2b 100644
--- a/libgda/gda-server-operation.c
+++ b/libgda/gda-server-operation.c
@@ -1998,7 +1998,7 @@ gda_server_operation_del_item_from_sequence (GdaServerOperation *op, const gchar
  *
  * Get the value for the node at the @path path
  *
- * Returns: (transfer none): a constant #GValue if a value has been defined, or %NULL if the value is undefined or if the @path is not defined or @path does not hold any value.
+ * Returns: (transfer none) (allow-none): a constant #GValue if a value has been defined, or %NULL if the value is undefined or if the @path is not defined or @path does not hold any value.
  *
  * Since: 4.2.6
  *
diff --git a/libgda/libgda-5.0.vapi b/libgda/libgda-5.0.vapi
index c4cb918..ed58303 100644
--- a/libgda/libgda-5.0.vapi
+++ b/libgda/libgda-5.0.vapi
@@ -335,6 +335,8 @@ namespace Gda {
 		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 {
@@ -746,7 +748,8 @@ namespace Gda {
 		public unowned string get_sequence_name (string path);
 		public uint get_sequence_size (string path);
 		public string get_sql_identifier_at_path (Gda.Connection? cnc, Gda.ServerProvider? prov, string path);
-		public GLib.Value get_value_at_path (string path);
+		[CCode (cname = "gda_server_operation_get_value_at_path")]
+		public unowned GLib.Value? get_value_at (string path);
 		public bool is_valid (string? xml_file) throws GLib.Error;
 		public bool load_data_from_xml ([CCode (type = "xmlNodePtr")] Xml.Node* node) throws GLib.Error;
 		public static unowned string op_type_to_string (Gda.ServerOperationType type);
diff --git a/tests/vala/CheckTable.vala b/tests/vala/CheckTable.vala
index 78d0d89..773fbcc 100644
--- a/tests/vala/CheckTable.vala
+++ b/tests/vala/CheckTable.vala
@@ -380,6 +380,40 @@ namespace Check {
 			return fails;
 		}
 		
+		public int save ()
+			throws Error
+		{
+			stdout.printf("\n\n\n>>>>>>>>>>>>>>> NEW TEST: Gda.DbTable - Rename ...\n");
+			int fails = 0;
+			
+			var t = new Table ();
+			t.name = "customer";
+			t.connection = connection;
+			try {
+				t.save ();
+				stdout.printf ("Table save() method should throws Error: FAIL\n");
+				fails++;
+			}
+			catch {}
+			
+			t.name = "customer2";
+			t.save ();
+			try {
+				var m = connection.execute_select_command ("SELECT * FROM customer2");
+				stdout.printf ("Data from customer2:\n" + m.dump_as_string ());
+			}
+			catch {
+				fails++;
+				stdout.printf ("Table rename: FAIL\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.DbTable implementation... <<<<<<<<<< \n");
 			int failures = 0;
@@ -391,7 +425,7 @@ namespace Check {
 				failures += app.records ();
 				//failures += app.expression ();
 				failures += app.append ();
-				//failures += app.save ();
+				failures += app.save ();
 			}
 			catch (Error e) 
 			{ 



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