Skip to content

Commit

Permalink
add DuckDB::Appender#append_default
Browse files Browse the repository at this point in the history
  • Loading branch information
suketa committed Nov 23, 2024
1 parent c424384 commit a2c632c
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions ext/duckdb/appender.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ static VALUE appender_append_varchar(VALUE self, VALUE val);
static VALUE appender_append_varchar_length(VALUE self, VALUE val, VALUE len);
static VALUE appender_append_blob(VALUE self, VALUE val);
static VALUE appender_append_null(VALUE self);
static VALUE appender_append_default(VALUE self);
static VALUE appender__append_date(VALUE self, VALUE yearval, VALUE monthval, VALUE dayval);
static VALUE appender__append_interval(VALUE self, VALUE months, VALUE days, VALUE micros);
static VALUE appender__append_time(VALUE self, VALUE hour, VALUE min, VALUE sec, VALUE micros);
Expand Down Expand Up @@ -281,6 +282,16 @@ static VALUE appender_append_null(VALUE self) {
return self;
}

static VALUE appender_append_default(VALUE self) {
rubyDuckDBAppender *ctx;
TypedData_Get_Struct(self, rubyDuckDBAppender, &appender_data_type, ctx);

if (duckdb_append_default(ctx->appender) == DuckDBError) {
rb_raise(eDuckDBError, "failed to append");
}
return self;
}

static VALUE appender__append_date(VALUE self, VALUE year, VALUE month, VALUE day) {
duckdb_date dt;
rubyDuckDBAppender *ctx;
Expand Down Expand Up @@ -406,6 +417,7 @@ void rbduckdb_init_duckdb_appender(void) {
rb_define_method(cDuckDBAppender, "append_varchar_length", appender_append_varchar_length, 2);
rb_define_method(cDuckDBAppender, "append_blob", appender_append_blob, 1);
rb_define_method(cDuckDBAppender, "append_null", appender_append_null, 0);
rb_define_method(cDuckDBAppender, "append_default", appender_append_default, 0);
rb_define_private_method(cDuckDBAppender, "_append_date", appender__append_date, 3);
rb_define_private_method(cDuckDBAppender, "_append_interval", appender__append_interval, 3);
rb_define_private_method(cDuckDBAppender, "_append_time", appender__append_time, 4);
Expand Down

0 comments on commit a2c632c

Please sign in to comment.