aboutsummaryrefslogtreecommitdiff
path: root/qlite
diff options
context:
space:
mode:
authorfiaxh <git@mx.ax.lt>2017-10-29 15:15:28 +0100
committerfiaxh <git@mx.ax.lt>2017-10-31 15:41:45 +0100
commit0102abeec1d2055b19dccbb7edc7f06e527642b1 (patch)
tree4018e82224c19142c4a7a6eced67d9c2550b2dd8 /qlite
parentb9df78e4494879752e9e68dcc5d54e03fffe9467 (diff)
downloaddino-0102abeec1d2055b19dccbb7edc7f06e527642b1.tar.gz
dino-0102abeec1d2055b19dccbb7edc7f06e527642b1.zip
Fix warnings
Diffstat (limited to 'qlite')
-rw-r--r--qlite/src/database.vala2
-rw-r--r--qlite/src/table.vala30
2 files changed, 24 insertions, 8 deletions
diff --git a/qlite/src/database.vala b/qlite/src/database.vala
index ad8505be..b153be73 100644
--- a/qlite/src/database.vala
+++ b/qlite/src/database.vala
@@ -129,7 +129,7 @@ public class Database {
return statement;
}
- public void exec(string sql) {
+ public void exec(string sql) throws Error {
ensure_init();
if (db.exec(sql) != OK) {
throw new Error(-1, 0, @"SQLite error: $(db.errcode()) - $(db.errmsg())");
diff --git a/qlite/src/table.vala b/qlite/src/table.vala
index 0d9fe2f6..00b4ef00 100644
--- a/qlite/src/table.vala
+++ b/qlite/src/table.vala
@@ -102,14 +102,22 @@ public class Table {
}
}
sql += @"$constraints)";
- db.exec(sql);
+ try {
+ db.exec(sql);
+ } catch (Error e) {
+ error("Qlite Error: Create table at version");
+ }
}
public void add_columns_for_version(long old_version, long new_version) {
ensure_init();
foreach (Column c in columns) {
if (c.min_version <= new_version && c.max_version >= new_version && c.min_version > old_version) {
- db.exec(@"ALTER TABLE $name ADD COLUMN $c");
+ try {
+ db.exec(@"ALTER TABLE $name ADD COLUMN $c");
+ } catch (Error e) {
+ error("Qlite Error: Add columns for version");
+ }
}
}
}
@@ -130,16 +138,24 @@ public class Table {
}
}
if (column_deletion_required) {
- db.exec(@"ALTER TABLE $name RENAME TO _$(name)_$old_version");
- create_table_at_version(new_version);
- db.exec(@"INSERT INTO $name ($column_list) SELECT $column_list FROM _$(name)_$old_version");
- db.exec(@"DROP TABLE _$(name)_$old_version");
+ try {
+ db.exec(@"ALTER TABLE $name RENAME TO _$(name)_$old_version");
+ create_table_at_version(new_version);
+ db.exec(@"INSERT INTO $name ($column_list) SELECT $column_list FROM _$(name)_$old_version");
+ db.exec(@"DROP TABLE _$(name)_$old_version");
+ } catch (Error e) {
+ error("Qlite Error: Delete volumns for version change");
+ }
}
}
internal void post() {
foreach (string stmt in post_statements) {
- db.exec(stmt);
+ try {
+ db.exec(stmt);
+ } catch (Error e) {
+ error("Qlite Error: Post");
+ }
}
}
}