Skip to content

Commit

Permalink
show warning on update or delete
Browse files Browse the repository at this point in the history
  • Loading branch information
dgllghr committed Jan 30, 2024
1 parent cd47ec8 commit dc52813
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 8 additions & 2 deletions src/Table.zig
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ pending_inserts: PendingInserts,
row_group_creator: RowGroupCreator,
dirty: bool,

warned_update_delete_not_supported: bool = false,

pub const InitError = error{
NoColumns,
UnsupportedDb,
Expand Down Expand Up @@ -300,7 +302,8 @@ pub fn update(
rowid: *i64,
change_set: ChangeSet,
) !void {
if (change_set.changeType() == .Insert) {
const change_type = change_set.changeType();
if (change_type == .Insert) {
rowid.* = self.pending_inserts.insert(cb_ctx.arena, change_set) catch |e| {
cb_ctx.setErrorMessage("failed insert insert entry: {any}", .{e});
return e;
Expand All @@ -311,7 +314,10 @@ pub fn update(
return;
}

@panic("delete and update are not supported");
if (!self.warned_update_delete_not_supported) {
std.log.warn("stanchion tables do not (yet) support UPDATE or DELETE", .{});
self.warned_update_delete_not_supported = true;
}
}

const BestIndexError = error{} || Allocator.Error || vtab.BestIndexError;
Expand Down
2 changes: 1 addition & 1 deletion src/sqlite3/ChangeSet.zig
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub fn init(values: []?*c.sqlite3_value) Self {
}

pub fn changeType(self: Self) ChangeType {
if (self.values.len == 0) {
if (self.values.len == 1) {
return .Delete;
}
if ((ValueRef{ .value = self.values[0] }).isNull()) {
Expand Down

0 comments on commit dc52813

Please sign in to comment.