[libgda] GdaData.Object.table API change: changed to read-only attribute.
- From: Daniel Espinosa Ortiz <despinosa src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgda] GdaData.Object.table API change: changed to read-only attribute.
- Date: Wed, 21 Dec 2011 16:17:48 +0000 (UTC)
commit 6e5992a4de52dcaabf5fcc389ff99039c63d75aa
Author: Daniel Espinosa <despinosa src gnome org>
Date: Mon Dec 19 11:18:54 2011 -0600
GdaData.Object.table API change: changed to read-only attribute.
* GdaData.Object.table must be overrided by derived classes maybe using an static string or any other method.
libgda/data/DataObject.vala | 3 ++-
libgda/data/GdaData-5.0.gir | 8 +++++---
samples/vala/SampleDataObject.vala | 32 ++++++++++++++------------------
tests/vala/CheckDataObject.vala | 3 +--
4 files changed, 22 insertions(+), 24 deletions(-)
---
diff --git a/libgda/data/DataObject.vala b/libgda/data/DataObject.vala
index 7f13fcb..c7bf197 100644
--- a/libgda/data/DataObject.vala
+++ b/libgda/data/DataObject.vala
@@ -19,6 +19,7 @@
using Gda;
+[CCode (gir_namespace = "GdaData", gir_version = "5.0")]
[CCode (cheader_filename="libgdadata.h")]
namespace GdaData {
@@ -28,7 +29,7 @@ namespace GdaData {
private Value? _id_value;
private DataModelIterable _model;
- public abstract string table { get; construct; }
+ public abstract string table { get; }
public DataModelIterable record {
get {
diff --git a/libgda/data/GdaData-5.0.gir b/libgda/data/GdaData-5.0.gir
index d9e2f4c..6d7b824 100644
--- a/libgda/data/GdaData-5.0.gir
+++ b/libgda/data/GdaData-5.0.gir
@@ -1,11 +1,13 @@
<?xml version="1.0"?>
<repository version="1.2" xmlns="http://www.gtk.org/introspection/core/1.0" xmlns:c="http://www.gtk.org/introspection/c/1.0" xmlns:glib="http://www.gtk.org/introspection/glib/1.0">
<include name="GObject" version="2.0"/>
-<include name="Gee" version="0.8"/>
<include name="Gda" version="5.0"/>
+<include name="Gee" version="0.8"/>
<package name="gdadata-5.0"/>
-<c:include name="libgdadata.h"/>
+<c:include name="../../libgda/libgdadata.h"/>
<namespace name="GdaData" version="5.0" c:prefix="GdaData">
+ <annotation key="ccode.gir-version" value="5.0"/>
+ <annotation key="ccode.gir-namespace" value="GdaData"/>
<annotation key="ccode.cheader-filename" value="libgdadata.h"/>
<class name="Object" c:type="GdaDataObject" glib:type-name="GdaDataObject" glib:get-type="gda_data_object_get_type" glib:type-struct="ObjectClass" parent="GObject.Object" abstract="1">
<field name="parent_instance">
@@ -80,7 +82,7 @@
<type name="Gda.SqlBuilder" c:type="GdaSqlBuilder*"/>
</return-value>
</method>
- <property name="table" writable="1" construct-only="1">
+ <property name="table">
<type name="utf8" c:type="gchar*"/>
</property>
<property name="record">
diff --git a/samples/vala/SampleDataObject.vala b/samples/vala/SampleDataObject.vala
index 0f8732a..5d6fee3 100644
--- a/samples/vala/SampleDataObject.vala
+++ b/samples/vala/SampleDataObject.vala
@@ -74,7 +74,7 @@ namespace Sample {
}
}
- public Gda.Numeric balance {
+ public double balance {
get {
string sql_debit = @"SELECT sum (debit) FROM transactions WHERE account = $id";
string sql_credit = @"SELECT sum (credit) FROM transactions WHERE account = $id";
@@ -82,9 +82,7 @@ namespace Sample {
var model_debit = this.connection.execute_select (sql_debit);
var credit = model_credit.get_value_at (0, 0);
var debit = model_debit.get_value_at (0, 0);
- var balance = (double) credit - (double) debit;
- var ret = new Gda.Numeric ();
- ret.set_from_string (ret.parse ());
+ return (double) credit - (double) debit;
}
}
@@ -155,10 +153,10 @@ namespace Sample {
}
}
- class App : GdaData.Object {
+ class App : GLib.Object {
public Gda.Connection connection;
- Tests()
+ App ()
{
try {
GLib.FileUtils.unlink("dataobject.db");
@@ -173,9 +171,10 @@ namespace Sample {
this.connection.execute_non_select_command("CREATE TABLE account (id int PRIMARY KEY AUTOINCREMENT, name string UNIQUE, description string)");
this.connection.execute_non_select_command("INSERT INTO account (id, name) VALUES (1, \"Incomes\"");
this.connection.execute_non_select_command("INSERT INTO account (id, name) VALUES (2, \"Expenses\"");
- this.connection.execute_non_select_command("CREATE TABLE transaction (id int PRIMARY KEY AUTOINCREMENT, account int, description string, amount double, credit bool)");
- this.connection.execute_non_select_command("INSERT INTO account (id, description, amount, credit) VALUES (1, \"Salary\"", );
- this.connection.execute_non_select_command("INSERT INTO account (id, name) VALUES (2, \"Expenses\"");
+ this.connection.execute_non_select_command("INSERT INTO account (id, name) VALUES (3, \"Bank\"");
+ this.connection.execute_non_select_command("CREATE TABLE transaction (id int PRIMARY KEY AUTOINCREMENT, credit int, debit int, description string, amount double)");
+ this.connection.execute_non_select_command("INSERT INTO account (id, credit, debit, description, amount, credit) VALUES (1, 3, 1, \"Salary\", 3100.0, TRUE");
+ this.connection.execute_non_select_command("INSERT INTO account (id, credit, debit, description, amount, credit) VALUES (2, 2, 3, \"Expenses of the week\"");
this.connection.update_meta_store(null);
}
catch (Error e) {
@@ -183,18 +182,15 @@ namespace Sample {
}
}
- public int get_value ()
- throws Error
- {
-
- return 0;
- }
-
+
public static int main (string[] args) {
stdout.printf ("Checking Gda.DataObject implementation...\n");
int failures = 0;
- var app = new Tests ();
- failures += app.t1 ();
+ var app = new App ();
+ app.get_balance ("Incomes");
+ app.get_balance ("Expenses");
+ app.get_balance ("Bank");
+ app.get_operations ("Bank");
return failures != 0 ? 1 : 0;
}
}
diff --git a/tests/vala/CheckDataObject.vala b/tests/vala/CheckDataObject.vala
index 8d0f746..d58e3e1 100644
--- a/tests/vala/CheckDataObject.vala
+++ b/tests/vala/CheckDataObject.vala
@@ -22,10 +22,9 @@ using GdaData;
namespace Check {
class Tests : GdaData.Object {
- private string t;
+ private static string t = "user";
public override string table {
get { return this.t; }
- construct { this.t = "user"; }
}
Tests()
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]