duckdb 1.1.3.1 → 1.2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 97d0a0fdf67bcfdd00102540f9dd675e1fe87176e349ef06db6f1c72f78b5219
4
- data.tar.gz: da34340b078ae95c6b9fa7ddb872de4be16f3bc298169004761d532a9f378f20
3
+ metadata.gz: 4ed07310471afbddcd5b4facd1720eeae0868af7d2682754a30361bafdf45b5a
4
+ data.tar.gz: 984fd1ac1d47a72c0d20a2b1225656baf8838a47c70c3edc54d58bde0490cf25
5
5
  SHA512:
6
- metadata.gz: 924d05547e0f9bf6f4772db3a93085930cd48961a0eee92d114815ea8286cd4ad6d1454764ffd97caa0cc6be103a2b084d1f402e98a973dc529b674754b4cfd7
7
- data.tar.gz: 022f30d9b659b487f109d91b7d9818a26bb6d0a7fffd62fc8ae0375453688b3981b652fcb00826a826f15503ee119ca73830fe251329d51235d46ffa6c17ff50
6
+ metadata.gz: 5e85e65243f72ac9d1d8bab1ec44a18b7ac31dccba3cfd12dc81c075f44ea79592b7357dde7f30b4276fda2eee769aa93986ca216061ea2aa497a7e7038872df
7
+ data.tar.gz: ee8db3baf4385b71e4c4d4765200baacef1df273702281e33809d2b4037bc25b4bae008e0501c178f615ba22f5a1b99021a22d15d5982054dbe675a769ca1cd8
@@ -0,0 +1,34 @@
1
+ name: Deploy RDoc to GitHub Pages
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+
8
+ jobs:
9
+ deploy:
10
+ name: Build and Deploy RDoc
11
+ runs-on: ubuntu-latest
12
+
13
+ steps:
14
+ # リポジトリをクローン
15
+ - name: Checkout code
16
+ uses: actions/checkout@v3
17
+
18
+ # Ruby をセットアップ
19
+ - name: Set up Ruby
20
+ uses: ruby/setup-ruby@v1
21
+ with:
22
+ ruby-version: 3.4
23
+
24
+ # RDoc ドキュメントを生成
25
+ - name: Generate RDoc
26
+ run: rdoc -o docs
27
+
28
+ # GitHub Pages 用にデプロイ
29
+ - name: Deploy to GitHub Pages
30
+ uses: peaceiris/actions-gh-pages@v3
31
+ with:
32
+ github_token: ${{ secrets.GITHUB_TOKEN }}
33
+ publish_branch: gh-pages
34
+ publish_dir: ./docs
@@ -15,9 +15,8 @@ jobs:
15
15
  runs-on: macos-latest
16
16
  strategy:
17
17
  matrix:
18
- # ruby: ['3.1.6', '3.2.6', '3.3.6', '3.4.0-preview2', 'head']
19
- ruby: ['3.1.6', '3.2.6', '3.3.6', '3.4.0-preview2']
20
- duckdb: ['1.1.3', '1.1.1', '1.0.0']
18
+ ruby: ['3.1.6', '3.2.6', '3.3.6', '3.4.2', 'head']
19
+ duckdb: ['1.2.0', '1.1.3', '1.1.1', '1.0.0']
21
20
 
22
21
  steps:
23
22
  - uses: actions/checkout@v4
@@ -15,8 +15,8 @@ jobs:
15
15
  runs-on: ubuntu-latest
16
16
  strategy:
17
17
  matrix:
18
- ruby: ['3.1.6', '3.2.6', '3.3.6', '3.4.0-preview2', 'head']
19
- duckdb: ['1.1.3', '1.1.1', '1.0.0']
18
+ ruby: ['3.1.6', '3.2.6', '3.3.6', '3.4.2', 'head']
19
+ duckdb: ['1.2.0', '1.1.3', '1.1.1', '1.0.0']
20
20
 
21
21
  steps:
22
22
  - uses: actions/checkout@v4
@@ -15,8 +15,8 @@ jobs:
15
15
  runs-on: windows-latest
16
16
  strategy:
17
17
  matrix:
18
- ruby: ['3.1.6', '3.2.5', '3.3.5', 'ucrt', 'mingw', 'mswin', 'head']
19
- duckdb: ['1.1.3', '1.1.1', '1.0.0']
18
+ ruby: ['3.1.6', '3.2.6', '3.3.6', '3.4.1', 'ucrt', 'mingw', 'mswin', 'head']
19
+ duckdb: ['1.2.0', '1.1.3', '1.1.1', '1.0.0']
20
20
 
21
21
  steps:
22
22
  - uses: actions/checkout@v4
data/.gitignore CHANGED
@@ -16,3 +16,4 @@
16
16
  *.so
17
17
  Makefile
18
18
  ng_test
19
+ /docs/
data/.rdoc_options ADDED
@@ -0,0 +1,22 @@
1
+ ---
2
+ encoding: UTF-8
3
+ static_path: []
4
+ rdoc_include: []
5
+ charset: UTF-8
6
+ exclude:
7
+ - "~\\z"
8
+ - "\\.orig\\z"
9
+ - "\\.rej\\z"
10
+ - "\\.bak\\z"
11
+ - "\\.gemspec\\z"
12
+ - "ext/duckdb/extconf.rb"
13
+ - "Gemfile"
14
+ - "Gemfile.lock"
15
+ - "Rakefile"
16
+ - "getduckdb.sh"
17
+ - "rdoc.log"
18
+ - "tmp"
19
+ - "mkmf.log"
20
+ - "Dockerfile"
21
+ - "bin"
22
+ main_page: "README.md"
data/CHANGELOG.md CHANGED
@@ -2,6 +2,51 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
  # Unreleased
5
+
6
+ # 1.2.0.0 - 2025-02-24
7
+ - bump duckdb to 1.2.0.
8
+ - add `DuckDB::LogicalType` class(Thanks to @otegami).
9
+ - `DuckDB::LogicalType` class is under construction. `DuckDB::LogicalType#type`, `DuckDB::LogicalType#width`,
10
+ `DuckDB::LogicalType#scale`, `DuckDB::LogicalType#child_type`, `DuckDB::LogicalType#size`,
11
+ `DuckDB::LogicalType#key_type`, and `DuckDB::LogicalType#value_type` are available.
12
+ - add `DuckDB::Appender#error_message`.
13
+ - fix error message when `DuckDB::Appender#flush`, `DuckDB::Appender#close`, `DuckDB::Appender#end_row`,
14
+ `DuckDB::Appender#append_bool`, `DuckDB::Appender#append_int8`, `DuckDB::Appender#append_int16`,
15
+ `DuckDB::Appender#append_int32`, `DuckDB::Appender#append_int64`, `DuckDB::Appender#append_uint8` failed.
16
+ - `DuckDB::Appender#begin_row` does nothing. Only returns self. `DuckDB::Appender#end_row` is only required.
17
+ - bump ruby in CI. use 3.4.2 on MacOS and Ubuntu, 3.4.1 on Windows.
18
+
19
+ ## Breaking changes
20
+ - `DuckDB::Result#row_count`, `DuckDB::Result#row_size` are deprecated.
21
+ - `DuckDB::Result#use_chunk_each?`, `DuckDB::Result#use_chunk_each=` are deprecated.
22
+ - `DuckDB::Result#chunk_each` is deprecated.
23
+ - `DuckDB::Result#each` only works at first time because duckdb_chunk_each C-API is deprecated.
24
+ Calling `DuckDB::Result#each` twice or more does not work.
25
+ ```ruby
26
+ result = con.query('SELECT * FROM table')
27
+ result.each do |record|
28
+ p record # <= this works fine.
29
+ end
30
+ # calling each again does not work.
31
+ result.each do |record|
32
+ p record # <= this will not work
33
+ end
34
+ ```
35
+ If you prefer to use `DuckDB::Result#each` multiple times, set `DuckDB::Result.use_chunk_each = true`.
36
+ But this behavior will be removed in the future release.
37
+ ```ruby
38
+ DuckDB::Result.use_chunk_each = true
39
+ result = con.query('SELECT * FROM table')
40
+ result.each do |record|
41
+ p record # <= this works fine.
42
+ end
43
+ # calling each again works.
44
+ result.each do |record|
45
+ p record # <= this works fine.
46
+ end
47
+ ```
48
+ - `DuckDB::Result#streaming?` will be deprecated.
49
+
5
50
  # 1.1.3.1 - 2024-11-27
6
51
  - fix to `DuckDB::Connection#query` with multiple SQL statements. Calling PreparedStatement#destroy after each statement executed.
7
52
  - install valgrind in docker development environment.
data/Dockerfile CHANGED
@@ -1,7 +1,7 @@
1
- ARG RUBY_VERSION=3.3.6
1
+ ARG RUBY_VERSION=3.4.2
2
2
  FROM ruby:${RUBY_VERSION}
3
3
 
4
- ARG DUCKDB_VERSION=1.1.3
4
+ ARG DUCKDB_VERSION=1.2.0
5
5
  ARG VALGRIND_VERSION=3.21.0
6
6
 
7
7
  RUN apt update -qq && \
data/Gemfile.lock CHANGED
@@ -1,34 +1,36 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- duckdb (1.1.3.1)
4
+ duckdb (1.2.0.0)
5
5
  bigdecimal (>= 3.1.4)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
10
  benchmark-ips (2.14.0)
11
- bigdecimal (3.1.8)
12
- minitest (5.25.2)
13
- nokogiri (1.16.7-aarch64-linux)
11
+ bigdecimal (3.1.9)
12
+ mini_portile2 (2.8.8)
13
+ minitest (5.25.4)
14
+ nokogiri (1.18.3)
15
+ mini_portile2 (~> 2.8.2)
14
16
  racc (~> 1.4)
15
- nokogiri (1.16.7-arm-linux)
17
+ nokogiri (1.18.3-aarch64-linux-gnu)
16
18
  racc (~> 1.4)
17
- nokogiri (1.16.7-arm64-darwin)
19
+ nokogiri (1.18.3-arm-linux-gnu)
18
20
  racc (~> 1.4)
19
- nokogiri (1.16.7-x86-linux)
21
+ nokogiri (1.18.3-arm64-darwin)
20
22
  racc (~> 1.4)
21
- nokogiri (1.16.7-x86_64-darwin)
23
+ nokogiri (1.18.3-x86_64-darwin)
22
24
  racc (~> 1.4)
23
- nokogiri (1.16.7-x86_64-linux)
25
+ nokogiri (1.18.3-x86_64-linux-gnu)
24
26
  racc (~> 1.4)
25
27
  racc (1.8.1)
26
28
  rake (13.2.1)
27
- rake-compiler (1.2.8)
29
+ rake-compiler (1.2.9)
28
30
  rake
29
- ruby_memcheck (3.0.0)
31
+ ruby_memcheck (3.0.1)
30
32
  nokogiri
31
- stackprof (0.2.26)
33
+ stackprof (0.2.27)
32
34
 
33
35
  PLATFORMS
34
36
  aarch64-linux
data/README.md CHANGED
@@ -65,6 +65,8 @@ gem install duckdb -- --with-duckdb-include=/duckdb_header_directory --with-duck
65
65
 
66
66
  ## Usage
67
67
 
68
+ The followings are some examples, for more detailed information, please refer to the [documentation](https://suketa.github.io/ruby-duckdb/index.html).
69
+
68
70
  ```ruby
69
71
  require 'duckdb'
70
72
 
@@ -218,7 +220,6 @@ def append
218
220
  appender = con.appender('users')
219
221
 
220
222
  10000.times do
221
- appender.begin_row
222
223
  appender.append(1)
223
224
  appender.append('Alice')
224
225
  appender.end_row
data/duckdb.gemspec CHANGED
@@ -15,6 +15,7 @@ Gem::Specification.new do |spec|
15
15
  spec.homepage = 'https://github.com/suketa/ruby-duckdb'
16
16
  spec.license = 'MIT'
17
17
 
18
+ spec.metadata['rubygems_mfa_required'] = 'true'
18
19
  spec.metadata['homepage_uri'] = spec.homepage
19
20
  spec.metadata['source_code_uri'] = 'https://github.com/suketa/ruby-duckdb'
20
21
  spec.metadata['changelog_uri'] = 'https://github.com/suketa/ruby-duckdb/blob/master/CHANGELOG.md'
@@ -6,14 +6,13 @@ static void deallocate(void *);
6
6
  static VALUE allocate(VALUE klass);
7
7
  static size_t memsize(const void *p);
8
8
  static VALUE appender_initialize(VALUE klass, VALUE con, VALUE schema, VALUE table);
9
- static VALUE appender_begin_row(VALUE self);
10
- static VALUE appender_end_row(VALUE self);
11
- static VALUE appender_append_bool(VALUE self, VALUE val);
12
- static VALUE appender_append_int8(VALUE self, VALUE val);
13
- static VALUE appender_append_int16(VALUE self, VALUE val);
14
- static VALUE appender_append_int32(VALUE self, VALUE val);
15
- static VALUE appender_append_int64(VALUE self, VALUE val);
16
- static VALUE appender_append_uint8(VALUE self, VALUE val);
9
+ static VALUE appender_error_message(VALUE self);
10
+ static VALUE appender__append_bool(VALUE self, VALUE val);
11
+ static VALUE appender__append_int8(VALUE self, VALUE val);
12
+ static VALUE appender__append_int16(VALUE self, VALUE val);
13
+ static VALUE appender__append_int32(VALUE self, VALUE val);
14
+ static VALUE appender__append_int64(VALUE self, VALUE val);
15
+ static VALUE appender__append_uint8(VALUE self, VALUE val);
17
16
  static VALUE appender_append_uint16(VALUE self, VALUE val);
18
17
  static VALUE appender_append_uint32(VALUE self, VALUE val);
19
18
  static VALUE appender_append_uint64(VALUE self, VALUE val);
@@ -28,14 +27,16 @@ static VALUE appender_append_null(VALUE self);
28
27
  static VALUE appender_append_default(VALUE self);
29
28
  #endif
30
29
 
30
+ static VALUE appender__end_row(VALUE self);
31
31
  static VALUE appender__append_date(VALUE self, VALUE yearval, VALUE monthval, VALUE dayval);
32
32
  static VALUE appender__append_interval(VALUE self, VALUE months, VALUE days, VALUE micros);
33
33
  static VALUE appender__append_time(VALUE self, VALUE hour, VALUE min, VALUE sec, VALUE micros);
34
34
  static VALUE appender__append_timestamp(VALUE self, VALUE year, VALUE month, VALUE day, VALUE hour, VALUE min, VALUE sec, VALUE micros);
35
35
  static VALUE appender__append_hugeint(VALUE self, VALUE lower, VALUE upper);
36
36
  static VALUE appender__append_uhugeint(VALUE self, VALUE lower, VALUE upper);
37
- static VALUE appender_flush(VALUE self);
38
- static VALUE appender_close(VALUE self);
37
+ static VALUE appender__flush(VALUE self);
38
+ static VALUE appender__close(VALUE self);
39
+ static VALUE duckdb_state_to_bool_value(duckdb_state state);
39
40
 
40
41
  static const rb_data_type_t appender_data_type = {
41
42
  "DuckDB/Appender",
@@ -82,27 +83,40 @@ static VALUE appender_initialize(VALUE self, VALUE con, VALUE schema, VALUE tabl
82
83
  return self;
83
84
  }
84
85
 
85
- static VALUE appender_begin_row(VALUE self) {
86
+ /* call-seq:
87
+ * appender.error_message -> String
88
+ *
89
+ * Returns the error message of the appender. If there is no error, then it returns nil.
90
+ *
91
+ * require 'duckdb'
92
+ * db = DuckDB::Database.open
93
+ * con = db.connect
94
+ * con.query('CREATE TABLE users (id INTEGER, name VARCHAR)')
95
+ * appender = con.appender('users')
96
+ * appender.error_message # => nil
97
+ */
98
+ static VALUE appender_error_message(VALUE self) {
86
99
  rubyDuckDBAppender *ctx;
100
+ const char *msg;
87
101
  TypedData_Get_Struct(self, rubyDuckDBAppender, &appender_data_type, ctx);
88
102
 
89
- if (duckdb_appender_begin_row(ctx->appender) == DuckDBError) {
90
- rb_raise(eDuckDBError, "failed to flush");
103
+ msg = duckdb_appender_error(ctx->appender);
104
+ if (msg == NULL) {
105
+ return Qnil;
91
106
  }
92
- return self;
107
+ return rb_str_new2(msg);
93
108
  }
94
109
 
95
- static VALUE appender_end_row(VALUE self) {
110
+ /* :nodoc: */
111
+ static VALUE appender__end_row(VALUE self) {
96
112
  rubyDuckDBAppender *ctx;
97
113
  TypedData_Get_Struct(self, rubyDuckDBAppender, &appender_data_type, ctx);
98
114
 
99
- if (duckdb_appender_end_row(ctx->appender) == DuckDBError) {
100
- rb_raise(eDuckDBError, "failed to flush");
101
- }
102
- return self;
115
+ return duckdb_state_to_bool_value(duckdb_appender_end_row(ctx->appender));
103
116
  }
104
117
 
105
- static VALUE appender_append_bool(VALUE self, VALUE val) {
118
+ /* :nodoc: */
119
+ static VALUE appender__append_bool(VALUE self, VALUE val) {
106
120
  rubyDuckDBAppender *ctx;
107
121
  TypedData_Get_Struct(self, rubyDuckDBAppender, &appender_data_type, ctx);
108
122
 
@@ -110,70 +124,57 @@ static VALUE appender_append_bool(VALUE self, VALUE val) {
110
124
  rb_raise(rb_eArgError, "argument must be boolean");
111
125
  }
112
126
 
113
- if (duckdb_append_bool(ctx->appender, (val == Qtrue)) == DuckDBError) {
114
- rb_raise(eDuckDBError, "failed to append boolean");
115
- }
116
- return self;
127
+ return duckdb_state_to_bool_value(duckdb_append_bool(ctx->appender, (val == Qtrue)));
117
128
  }
118
129
 
119
- static VALUE appender_append_int8(VALUE self, VALUE val) {
130
+ /* :nodoc: */
131
+ static VALUE appender__append_int8(VALUE self, VALUE val) {
120
132
  rubyDuckDBAppender *ctx;
121
133
  int8_t i8val = (int8_t)NUM2INT(val);
122
134
 
123
135
  TypedData_Get_Struct(self, rubyDuckDBAppender, &appender_data_type, ctx);
124
136
 
125
- if (duckdb_append_int8(ctx->appender, i8val) == DuckDBError) {
126
- rb_raise(eDuckDBError, "failed to append");
127
- }
128
- return self;
137
+ return duckdb_state_to_bool_value(duckdb_append_int8(ctx->appender, i8val));
129
138
  }
130
139
 
131
- static VALUE appender_append_int16(VALUE self, VALUE val) {
140
+ /* :nodoc: */
141
+ static VALUE appender__append_int16(VALUE self, VALUE val) {
132
142
  rubyDuckDBAppender *ctx;
133
143
  int16_t i16val = (int16_t)NUM2INT(val);
134
144
 
135
145
  TypedData_Get_Struct(self, rubyDuckDBAppender, &appender_data_type, ctx);
136
146
 
137
- if (duckdb_append_int16(ctx->appender, i16val) == DuckDBError) {
138
- rb_raise(eDuckDBError, "failed to append");
139
- }
140
- return self;
147
+ return duckdb_state_to_bool_value(duckdb_append_int16(ctx->appender, i16val));
141
148
  }
142
149
 
143
- static VALUE appender_append_int32(VALUE self, VALUE val) {
150
+ /* :nodoc: */
151
+ static VALUE appender__append_int32(VALUE self, VALUE val) {
144
152
  rubyDuckDBAppender *ctx;
145
153
  int32_t i32val = (int32_t)NUM2INT(val);
146
154
 
147
155
  TypedData_Get_Struct(self, rubyDuckDBAppender, &appender_data_type, ctx);
148
156
 
149
- if (duckdb_append_int32(ctx->appender, i32val) == DuckDBError) {
150
- rb_raise(eDuckDBError, "failed to append");
151
- }
152
- return self;
157
+ return duckdb_state_to_bool_value(duckdb_append_int32(ctx->appender, i32val));
153
158
  }
154
159
 
155
- static VALUE appender_append_int64(VALUE self, VALUE val) {
160
+ /* :nodoc: */
161
+ static VALUE appender__append_int64(VALUE self, VALUE val) {
156
162
  rubyDuckDBAppender *ctx;
157
163
  int64_t i64val = (int64_t)NUM2LL(val);
158
164
 
159
165
  TypedData_Get_Struct(self, rubyDuckDBAppender, &appender_data_type, ctx);
160
166
 
161
- if (duckdb_append_int64(ctx->appender, i64val) == DuckDBError) {
162
- rb_raise(eDuckDBError, "failed to append");
163
- }
164
- return self;
167
+ return duckdb_state_to_bool_value(duckdb_append_int64(ctx->appender, i64val));
165
168
  }
166
169
 
167
- static VALUE appender_append_uint8(VALUE self, VALUE val) {
170
+ /* :nodoc: */
171
+ static VALUE appender__append_uint8(VALUE self, VALUE val) {
168
172
  rubyDuckDBAppender *ctx;
169
- int8_t ui8val = (uint8_t)NUM2UINT(val);
173
+ uint8_t ui8val = (uint8_t)NUM2UINT(val);
170
174
 
171
175
  TypedData_Get_Struct(self, rubyDuckDBAppender, &appender_data_type, ctx);
172
176
 
173
- if (duckdb_append_uint8(ctx->appender, ui8val) == DuckDBError) {
174
- rb_raise(eDuckDBError, "failed to append");
175
- }
176
- return self;
177
+ return duckdb_state_to_bool_value(duckdb_append_uint8(ctx->appender, ui8val));
177
178
  }
178
179
 
179
180
  static VALUE appender_append_uint16(VALUE self, VALUE val) {
@@ -183,7 +184,7 @@ static VALUE appender_append_uint16(VALUE self, VALUE val) {
183
184
  TypedData_Get_Struct(self, rubyDuckDBAppender, &appender_data_type, ctx);
184
185
 
185
186
  if (duckdb_append_uint16(ctx->appender, ui16val) == DuckDBError) {
186
- rb_raise(eDuckDBError, "failed to append");
187
+ rb_raise(eDuckDBError, "failed to append uint16");
187
188
  }
188
189
  return self;
189
190
  }
@@ -195,7 +196,7 @@ static VALUE appender_append_uint32(VALUE self, VALUE val) {
195
196
  TypedData_Get_Struct(self, rubyDuckDBAppender, &appender_data_type, ctx);
196
197
 
197
198
  if (duckdb_append_uint32(ctx->appender, ui32val) == DuckDBError) {
198
- rb_raise(eDuckDBError, "failed to append");
199
+ rb_raise(eDuckDBError, "failed to append uint32");
199
200
  }
200
201
  return self;
201
202
  }
@@ -207,7 +208,7 @@ static VALUE appender_append_uint64(VALUE self, VALUE val) {
207
208
  TypedData_Get_Struct(self, rubyDuckDBAppender, &appender_data_type, ctx);
208
209
 
209
210
  if (duckdb_append_uint64(ctx->appender, ui64val) == DuckDBError) {
210
- rb_raise(eDuckDBError, "failed to append");
211
+ rb_raise(eDuckDBError, "failed to append uint64");
211
212
  }
212
213
  return self;
213
214
  }
@@ -219,7 +220,7 @@ static VALUE appender_append_float(VALUE self, VALUE val) {
219
220
  TypedData_Get_Struct(self, rubyDuckDBAppender, &appender_data_type, ctx);
220
221
 
221
222
  if (duckdb_append_float(ctx->appender, fval) == DuckDBError) {
222
- rb_raise(eDuckDBError, "failed to append");
223
+ rb_raise(eDuckDBError, "failed to append float");
223
224
  }
224
225
  return self;
225
226
  }
@@ -231,7 +232,7 @@ static VALUE appender_append_double(VALUE self, VALUE val) {
231
232
  TypedData_Get_Struct(self, rubyDuckDBAppender, &appender_data_type, ctx);
232
233
 
233
234
  if (duckdb_append_double(ctx->appender, dval) == DuckDBError) {
234
- rb_raise(eDuckDBError, "failed to append");
235
+ rb_raise(eDuckDBError, "failed to append double");
235
236
  }
236
237
  return self;
237
238
  }
@@ -243,7 +244,7 @@ static VALUE appender_append_varchar(VALUE self, VALUE val) {
243
244
  TypedData_Get_Struct(self, rubyDuckDBAppender, &appender_data_type, ctx);
244
245
 
245
246
  if (duckdb_append_varchar(ctx->appender, pval) == DuckDBError) {
246
- rb_raise(eDuckDBError, "failed to append");
247
+ rb_raise(eDuckDBError, "failed to append varchar");
247
248
  }
248
249
  return self;
249
250
  }
@@ -257,7 +258,7 @@ static VALUE appender_append_varchar_length(VALUE self, VALUE val, VALUE len) {
257
258
  TypedData_Get_Struct(self, rubyDuckDBAppender, &appender_data_type, ctx);
258
259
 
259
260
  if (duckdb_append_varchar_length(ctx->appender, pval, length) == DuckDBError) {
260
- rb_raise(eDuckDBError, "failed to append");
261
+ rb_raise(eDuckDBError, "failed to append varchar with length");
261
262
  }
262
263
  return self;
263
264
  }
@@ -271,7 +272,7 @@ static VALUE appender_append_blob(VALUE self, VALUE val) {
271
272
  TypedData_Get_Struct(self, rubyDuckDBAppender, &appender_data_type, ctx);
272
273
 
273
274
  if (duckdb_append_blob(ctx->appender, (void *)pval, length) == DuckDBError) {
274
- rb_raise(eDuckDBError, "failed to append");
275
+ rb_raise(eDuckDBError, "failed to append blob");
275
276
  }
276
277
  return self;
277
278
  }
@@ -281,7 +282,7 @@ static VALUE appender_append_null(VALUE self) {
281
282
  TypedData_Get_Struct(self, rubyDuckDBAppender, &appender_data_type, ctx);
282
283
 
283
284
  if (duckdb_append_null(ctx->appender) == DuckDBError) {
284
- rb_raise(eDuckDBError, "failed to append");
285
+ rb_raise(eDuckDBError, "failed to append null");
285
286
  }
286
287
  return self;
287
288
  }
@@ -292,12 +293,13 @@ static VALUE appender_append_default(VALUE self) {
292
293
  TypedData_Get_Struct(self, rubyDuckDBAppender, &appender_data_type, ctx);
293
294
 
294
295
  if (duckdb_append_default(ctx->appender) == DuckDBError) {
295
- rb_raise(eDuckDBError, "failed to append");
296
+ rb_raise(eDuckDBError, "failed to append default");
296
297
  }
297
298
  return self;
298
299
  }
299
300
  #endif
300
301
 
302
+ /* :nodoc: */
301
303
  static VALUE appender__append_date(VALUE self, VALUE year, VALUE month, VALUE day) {
302
304
  duckdb_date dt;
303
305
  rubyDuckDBAppender *ctx;
@@ -311,6 +313,7 @@ static VALUE appender__append_date(VALUE self, VALUE year, VALUE month, VALUE da
311
313
  return self;
312
314
  }
313
315
 
316
+ /* :nodoc: */
314
317
  static VALUE appender__append_interval(VALUE self, VALUE months, VALUE days, VALUE micros) {
315
318
  duckdb_interval interval;
316
319
  rubyDuckDBAppender *ctx;
@@ -324,6 +327,7 @@ static VALUE appender__append_interval(VALUE self, VALUE months, VALUE days, VAL
324
327
  return self;
325
328
  }
326
329
 
330
+ /* :nodoc: */
327
331
  static VALUE appender__append_time(VALUE self, VALUE hour, VALUE min, VALUE sec, VALUE micros) {
328
332
  duckdb_time time;
329
333
  rubyDuckDBAppender *ctx;
@@ -337,6 +341,7 @@ static VALUE appender__append_time(VALUE self, VALUE hour, VALUE min, VALUE sec,
337
341
  return self;
338
342
  }
339
343
 
344
+ /* :nodoc: */
340
345
  static VALUE appender__append_timestamp(VALUE self, VALUE year, VALUE month, VALUE day, VALUE hour, VALUE min, VALUE sec, VALUE micros) {
341
346
  duckdb_timestamp timestamp;
342
347
 
@@ -352,6 +357,7 @@ static VALUE appender__append_timestamp(VALUE self, VALUE year, VALUE month, VAL
352
357
  return self;
353
358
  }
354
359
 
360
+ /* :nodoc: */
355
361
  static VALUE appender__append_hugeint(VALUE self, VALUE lower, VALUE upper) {
356
362
  duckdb_hugeint hugeint;
357
363
 
@@ -367,6 +373,7 @@ static VALUE appender__append_hugeint(VALUE self, VALUE lower, VALUE upper) {
367
373
  return self;
368
374
  }
369
375
 
376
+ /* :nodoc: */
370
377
  static VALUE appender__append_uhugeint(VALUE self, VALUE lower, VALUE upper) {
371
378
  duckdb_uhugeint uhugeint;
372
379
 
@@ -382,38 +389,37 @@ static VALUE appender__append_uhugeint(VALUE self, VALUE lower, VALUE upper) {
382
389
  return self;
383
390
  }
384
391
 
385
- static VALUE appender_flush(VALUE self) {
392
+ /* :nodoc: */
393
+ static VALUE appender__flush(VALUE self) {
386
394
  rubyDuckDBAppender *ctx;
387
395
  TypedData_Get_Struct(self, rubyDuckDBAppender, &appender_data_type, ctx);
388
396
 
389
- if (duckdb_appender_flush(ctx->appender) == DuckDBError) {
390
- rb_raise(eDuckDBError, "failed to flush");
391
- }
392
- return self;
397
+ return duckdb_state_to_bool_value(duckdb_appender_flush(ctx->appender));
393
398
  }
394
399
 
395
- static VALUE appender_close(VALUE self) {
400
+ /* :nodoc: */
401
+ static VALUE appender__close(VALUE self) {
396
402
  rubyDuckDBAppender *ctx;
397
403
  TypedData_Get_Struct(self, rubyDuckDBAppender, &appender_data_type, ctx);
398
404
 
399
- if (duckdb_appender_close(ctx->appender) == DuckDBError) {
400
- rb_raise(eDuckDBError, "failed to flush");
405
+ return duckdb_state_to_bool_value(duckdb_appender_close(ctx->appender));
406
+ }
407
+
408
+ static VALUE duckdb_state_to_bool_value(duckdb_state state) {
409
+ if (state == DuckDBSuccess) {
410
+ return Qtrue;
401
411
  }
402
- return self;
412
+ return Qfalse;
403
413
  }
404
414
 
405
415
  void rbduckdb_init_duckdb_appender(void) {
416
+ #if 0
417
+ VALUE mDuckDB = rb_define_module("DuckDB");
418
+ #endif
406
419
  cDuckDBAppender = rb_define_class_under(mDuckDB, "Appender", rb_cObject);
407
420
  rb_define_alloc_func(cDuckDBAppender, allocate);
408
421
  rb_define_method(cDuckDBAppender, "initialize", appender_initialize, 3);
409
- rb_define_method(cDuckDBAppender, "begin_row", appender_begin_row, 0);
410
- rb_define_method(cDuckDBAppender, "end_row", appender_end_row, 0);
411
- rb_define_method(cDuckDBAppender, "append_bool", appender_append_bool, 1);
412
- rb_define_method(cDuckDBAppender, "append_int8", appender_append_int8, 1);
413
- rb_define_method(cDuckDBAppender, "append_int16", appender_append_int16, 1);
414
- rb_define_method(cDuckDBAppender, "append_int32", appender_append_int32, 1);
415
- rb_define_method(cDuckDBAppender, "append_int64", appender_append_int64, 1);
416
- rb_define_method(cDuckDBAppender, "append_uint8", appender_append_uint8, 1);
422
+ rb_define_method(cDuckDBAppender, "error_message", appender_error_message, 0);
417
423
  rb_define_method(cDuckDBAppender, "append_uint16", appender_append_uint16, 1);
418
424
  rb_define_method(cDuckDBAppender, "append_uint32", appender_append_uint32, 1);
419
425
  rb_define_method(cDuckDBAppender, "append_uint64", appender_append_uint64, 1);
@@ -428,12 +434,19 @@ void rbduckdb_init_duckdb_appender(void) {
428
434
  rb_define_method(cDuckDBAppender, "append_default", appender_append_default, 0);
429
435
  #endif
430
436
 
437
+ rb_define_private_method(cDuckDBAppender, "_end_row", appender__end_row, 0);
438
+ rb_define_private_method(cDuckDBAppender, "_flush", appender__flush, 0);
439
+ rb_define_private_method(cDuckDBAppender, "_close", appender__close, 0);
440
+ rb_define_private_method(cDuckDBAppender, "_append_bool", appender__append_bool, 1);
441
+ rb_define_private_method(cDuckDBAppender, "_append_int8", appender__append_int8, 1);
442
+ rb_define_private_method(cDuckDBAppender, "_append_int16", appender__append_int16, 1);
443
+ rb_define_private_method(cDuckDBAppender, "_append_int32", appender__append_int32, 1);
444
+ rb_define_private_method(cDuckDBAppender, "_append_int64", appender__append_int64, 1);
445
+ rb_define_private_method(cDuckDBAppender, "_append_uint8", appender__append_uint8, 1);
431
446
  rb_define_private_method(cDuckDBAppender, "_append_date", appender__append_date, 3);
432
447
  rb_define_private_method(cDuckDBAppender, "_append_interval", appender__append_interval, 3);
433
448
  rb_define_private_method(cDuckDBAppender, "_append_time", appender__append_time, 4);
434
449
  rb_define_private_method(cDuckDBAppender, "_append_timestamp", appender__append_timestamp, 7);
435
450
  rb_define_private_method(cDuckDBAppender, "_append_hugeint", appender__append_hugeint, 2);
436
451
  rb_define_private_method(cDuckDBAppender, "_append_uhugeint", appender__append_uhugeint, 2);
437
- rb_define_method(cDuckDBAppender, "flush", appender_flush, 0);
438
- rb_define_method(cDuckDBAppender, "close", appender_close, 0);
439
452
  }
data/ext/duckdb/blob.c CHANGED
@@ -3,5 +3,8 @@
3
3
  VALUE cDuckDBBlob;
4
4
 
5
5
  void rbduckdb_init_duckdb_blob(void) {
6
+ #if 0
7
+ VALUE mDuckDB = rb_define_module("DuckDB");
8
+ #endif
6
9
  cDuckDBBlob = rb_define_class_under(mDuckDB, "Blob", rb_cString);
7
10
  }