diff options
| author | frosty <frostinator33@airmail.cc> | 2026-10-26 10:21:57 -0400 |
|---|---|---|
| committer | frosty <frostinator33@airmail.cc> | 2026-10-26 10:21:57 -0400 |
| commit | 74aecd8b0986d07b50b7ce310d64e645b8b54e38 (patch) | |
| tree | 560e6434f183eb54cd779936f3a4c9575146a066 /qlite/src/delete_builder.vala | |
| parent | 3d7e90d401da02d430a87db0ec7e1db3a6f1a68f (diff) | |
| parent | 4436001bb361ad4f9e4e05819214ecf0ea77c063 (diff) | |
Merge 'upstream/master'
Diffstat (limited to 'qlite/src/delete_builder.vala')
| -rw-r--r-- | qlite/src/delete_builder.vala | 62 |
1 files changed, 0 insertions, 62 deletions
diff --git a/qlite/src/delete_builder.vala b/qlite/src/delete_builder.vala deleted file mode 100644 index 45e09dc7..00000000 --- a/qlite/src/delete_builder.vala +++ /dev/null @@ -1,62 +0,0 @@ -using Sqlite; - -namespace Qlite { - -public class DeleteBuilder : StatementBuilder { - - // DELETE FROM [...] - private Table? table; - private string table_name; - - // WHERE [...] - private string selection = "1"; - private StatementBuilder.AbstractField[] selection_args = {}; - - internal DeleteBuilder(Database db) { - base(db); - } - - public DeleteBuilder from(Table table) { - if (this.table != null) error("Qlite Error: ILLEGAL QUERY: cannot use from() multiple times."); - this.table = table; - this.table_name = table.name; - return this; - } - - public DeleteBuilder from_name(string table) { - this.table_name = table; - return this; - } - - public DeleteBuilder where(string selection, string[]? selection_args = null) { - if (this.selection != "1") error("selection was already done, but where() was called."); - this.selection = selection; - foreach (string arg in selection_args) { - this.selection_args += new StatementBuilder.StringField(arg); - } - return this; - } - - public DeleteBuilder with<T>(Column<T> column, string comp, T value) { - selection_args += new Field<T>(column, value); - selection = @"($selection) AND $(column.name) $comp ?"; - return this; - } - - internal override Statement prepare() { - Statement stmt = db.prepare(@"DELETE FROM $table_name WHERE $selection"); - for (int i = 0; i < selection_args.length; i++) { - selection_args[i].bind(stmt, i+1); - } - return stmt; - } - - public void perform() { - if (prepare().step() != DONE) { - critical(@"SQLite error: %d - %s", db.errcode(), db.errmsg()); - } - } - -} - -} |
