duckdb 0.0.8 → 0.0.12

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 743c5cd93509adeb83483bc5dfc363ef65a4b92aacc1c72b0845c2a5d722c913
4
- data.tar.gz: 93f5aac3993b0b1cd1512e1dd32fbcab216e6e2ab9b94df229b29d36c1bcd89e
3
+ metadata.gz: 1a0f6c8a46cecbe281cf970b5e8c6fd11c2903a5ddd58bf683341bcb299d7a36
4
+ data.tar.gz: 6ba452c2aa37f77c68905413e3bb6cb27697f8db23bfeca1e8ca1886ce6fb1ab
5
5
  SHA512:
6
- metadata.gz: c93239f6fe857b8761fa88a223be2a4b45e883291687feeaf1a2215ab0238d87a04d5d72a8854c2610a3333f6c282e6a17f81baae8fe61d8ebb4ce59801ad5ff
7
- data.tar.gz: c2b45b34783c366075a42c22765bf2406ebbaa5ee9024b3260003d20be4321b16efc565839f93ec3fd6a6e25582b7c1d12f265d8d56e92003b9eb40e26e51a58
6
+ metadata.gz: beb0db8d6e590ee4014aa4fb1e09a7093d6b13cebe3ad38f90cf6f29707b5e768696732f33c5d53027032ba7eacc8bf8ddecb9b112a042f05b17bbb98e086197
7
+ data.tar.gz: 228651ac8ed6c13044cbf0e3709444464ff552b0b431b051446def7dce074b38ef8a242f72e75c8c1ba788ae13dfc88a2041f7f2e9e70b64fb3c34c9c2c8ad85
@@ -0,0 +1,34 @@
1
+ name: MacOS
2
+
3
+ on: [push]
4
+
5
+ jobs:
6
+ build:
7
+ runs-on: macos-latest
8
+ strategy:
9
+ matrix:
10
+ ruby: ['2.5.8', '2.6.6', '2.7.2', '3.0.0', 'head']
11
+
12
+ steps:
13
+ - uses: actions/checkout@v2
14
+
15
+ - name: Set up Ruby
16
+ uses: ruby/setup-ruby@v1
17
+ with:
18
+ ruby-version: ${{ matrix.ruby }}
19
+
20
+ - name: Install duckdb
21
+ env:
22
+ DUCKDB_VERSION: 0.2.4
23
+ run: |
24
+ brew install duckdb
25
+ git clone -b v${DUCKDB_VERSION} https://github.com/cwida/duckdb.git duckdb-v${DUCKDB_VERSION}
26
+ cp duckdb-v${DUCKDB_VERSION}/src/include/duckdb.h /usr/local/include
27
+ mkdir -p /usr/local/include/duckdb/common
28
+ cp duckdb-v${DUCKDB_VERSION}/src/include/duckdb/common/winapi.hpp /usr/local/include/duckdb/common
29
+
30
+ - name: Build and test with Rake with Ruby ${{ matrix.ruby }}
31
+ run: |
32
+ ruby -v
33
+ bundle install --jobs 4 --retry 3
34
+ bundle exec rake
@@ -0,0 +1,66 @@
1
+ name: Ubuntu
2
+
3
+ on: [push]
4
+
5
+ jobs:
6
+ build:
7
+
8
+ runs-on: ubuntu-latest
9
+ strategy:
10
+ matrix:
11
+ ruby: ['2.5.8', '2.6.6', '2.7.2', '3.0.0', 'head']
12
+ duckdb: ['0.2.4', '0.2.5']
13
+
14
+ steps:
15
+ - uses: actions/checkout@v2
16
+
17
+ - name: Set up Ruby
18
+ uses: ruby/setup-ruby@v1
19
+ with:
20
+ ruby-version: ${{ matrix.ruby }}
21
+
22
+ - name: duckdb 0.2.4 cache
23
+ id: duckdb-cache-v0_2_4
24
+ uses: actions/cache@v1.1.0
25
+ with:
26
+ path: duckdb-v0.2.4
27
+ key: ${{ runner.os }}-duckdb-v0_2_4_001
28
+ restore-keys: |
29
+ ${{ runner.os }}-duckdb-v0_2_4
30
+
31
+ - name: duckdb 0.2.5 cache
32
+ id: duckdb-cache-v0_2_5
33
+ uses: actions/cache@v1.1.0
34
+ with:
35
+ path: duckdb-v0.2.5
36
+ key: ${{ runner.os }}-duckdb-v0_2_5_001
37
+ restore-keys: |
38
+ ${{ runner.os }}-duckdb-v0_2_5
39
+
40
+ - name: Build duckdb 0.2.4
41
+ if: steps.duckdb-cache-v0_2_4.outputs.cache-hit != 'true'
42
+ run: |
43
+ git clone -b v0.2.4 https://github.com/cwida/duckdb.git duckdb-tmp-v0.2.4
44
+ cd duckdb-tmp-v0.2.4 && make && cd ..
45
+ rm -rf duckdb-v0.2.4
46
+ mkdir -p duckdb-v0.2.4/build/release/src duckdb-v0.2.4/src
47
+ cp -rip duckdb-tmp-v0.2.4/build/release/src/*.so duckdb-v0.2.4/build/release/src
48
+ cp -rip duckdb-tmp-v0.2.4/src/include duckdb-v0.2.4/src/
49
+
50
+ - name: Build duckdb 0.2.5
51
+ if: steps.duckdb-cache-v0_2_5.outputs.cache-hit != 'true'
52
+ run: |
53
+ git clone -b v0.2.5 https://github.com/cwida/duckdb.git duckdb-tmp-v0.2.5
54
+ cd duckdb-tmp-v0.2.5 && make && cd ..
55
+ rm -rf duckdb-v0.2.5
56
+ mkdir -p duckdb-v0.2.5/build/release/src duckdb-v0.2.5/src
57
+ cp -rip duckdb-tmp-v0.2.5/build/release/src/*.so duckdb-v0.2.5/build/release/src
58
+ cp -rip duckdb-tmp-v0.2.5/src/include duckdb-v0.2.5/src/
59
+
60
+ - name: Build and test with Rake with Ruby ${{ matrix.ruby }}
61
+ env:
62
+ DUCKDB_VERSION: ${{ matrix.duckdb }}
63
+ run: |
64
+ gem install bundler
65
+ bundle install --jobs 4 --retry 3
66
+ bundle exec rake -- --with-duckdb-include=${GITHUB_WORKSPACE}/duckdb-v${DUCKDB_VERSION}/src/include --with-duckdb-lib=${GITHUB_WORKSPACE}/duckdb-v${DUCKDB_VERSION}/build/release/src/
data/.travis.yml CHANGED
@@ -2,17 +2,17 @@ language: ruby
2
2
  cache:
3
3
  bundler: true
4
4
  directories:
5
- - ${HOME}/duckdb-v0.1.9
5
+ - ${HOME}/duckdb-v0.2.5
6
6
  before_install:
7
7
  - yes | gem update --system
8
- - if [[ ! -d ${HOME}/duckdb-v0.1.9/build ]]; then cd ${HOME} && git clone -b v0.1.9 https://github.com/cwida/duckdb.git duckdb-v0.1.9 && cd duckdb-v0.1.9 && make && cd ${TRAVIS_BUILD_DIR}; fi
8
+ - if [[ ! -d ${HOME}/duckdb-v0.2.5/build ]]; then cd ${HOME} && git clone -b v0.2.5 https://github.com/cwida/duckdb.git duckdb-v0.2.5 && cd duckdb-v0.2.5 && make && cd ${TRAVIS_BUILD_DIR}; fi
9
9
 
10
10
  env:
11
- - DUCKDB_VERSION=0.1.9
11
+ - DUCKDB_VERSION=0.2.5
12
12
  rvm:
13
13
  - 2.5.8
14
14
  - 2.6.6
15
- - 2.7.0
16
- - 2.7.1
15
+ - 2.7.2
16
+ - 3.0.0
17
17
  - ruby-head
18
18
  script: bundle exec rake -- --with-duckdb-include=${HOME}/duckdb-v${DUCKDB_VERSION}/src/include --with-duckdb-lib=${HOME}/duckdb-v${DUCKDB_VERSION}/build/release/src/
data/CHANGELOG.md CHANGED
@@ -1,5 +1,34 @@
1
1
  # ChangeLog
2
2
 
3
+ ## 0.0.12
4
+
5
+ - bump DuckDB to v0.2.5
6
+ - support BLOB type (with DuckDB version 0.2.5 or later)
7
+
8
+ ## 0.0.11
9
+
10
+ - fix failure in test_close in test/duckdb_test/database_test.rb because DuckDB error message was changed.
11
+ - bump DuckDb to v0.2.4
12
+ - add test CI with Ruby 3.0.0
13
+ - add test CI on MacOS.
14
+ - bunp DuckDB to v0.2.3
15
+
16
+ ## 0.0.10
17
+
18
+ - bump DuckDB to v0.2.2
19
+ - fix to build failure on MacOS.
20
+
21
+ ## 0.0.9
22
+
23
+ - bump DuckDB to v0.2.1
24
+ - bump Ruby to v2.7.2
25
+ - bunmp DuckDB to v0.2.0
26
+
27
+ ## 0.0.8.1
28
+
29
+ - update Gemfile.lock
30
+ - unsupport Ruby 2.4
31
+
3
32
  ## 0.0.8
4
33
 
5
34
  - remove test with Ruby 2.4.10
data/Gemfile.lock CHANGED
@@ -1,18 +1,18 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- duckdb (0.0.7)
4
+ duckdb (0.0.12)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
- minitest (5.13.0)
10
- rake (13.0.1)
11
- rake-compiler (1.1.0)
9
+ minitest (5.14.4)
10
+ rake (13.0.3)
11
+ rake-compiler (1.1.1)
12
12
  rake
13
13
 
14
14
  PLATFORMS
15
- ruby
15
+ x86_64-linux
16
16
 
17
17
  DEPENDENCIES
18
18
  bundler (~> 2.0)
@@ -22,4 +22,4 @@ DEPENDENCIES
22
22
  rake-compiler
23
23
 
24
24
  BUNDLED WITH
25
- 2.1.4
25
+ 2.2.3
data/README.md CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  [![Build Status](https://travis-ci.com/suketa/ruby-duckdb.svg?branch=master)](https://travis-ci.com/suketa/ruby-duckdb)
4
4
  [![](https://github.com/suketa/ruby-duckdb/workflows/Ubuntu/badge.svg)](https://github.com/suketa/ruby-duckdb/actions?query=workflow%3AUbuntu)
5
+ [![](https://github.com/suketa/ruby-duckdb/workflows/MacOS/badge.svg)](https://github.com/suketa/ruby-duckdb/actions?query=workflow%3AMacOS)
5
6
 
6
7
  ## Description
7
8
 
@@ -63,3 +64,26 @@ DuckDB::Database.open do |db|
63
64
  end
64
65
  end
65
66
  ```
67
+
68
+ ### using BLOB column
69
+
70
+ BLOB is available with DuckDB v0.2.5 or later.
71
+ Use `DuckDB::Blob.new` or use sting#force_encoding(Encoding::ASCII_8BIT)
72
+
73
+ ```
74
+ require 'duckdb'
75
+
76
+ DuckDB::Database.open do |db|
77
+ db.connect do |con|
78
+ con.query('CREATE TABLE blob_table (binary_data BLOB)')
79
+ stmt = DuckDB::PreparedStatement.new(con, 'INSERT INTO blob_table VALUES ($1)')
80
+
81
+ stmt.bind(1, DuckDB::Blob.new("\0\1\2\3\4\5"))
82
+ # stmt.bind(1, "\0\1\2\3\4\5".force_encoding(Encoding::BINARY))
83
+ stmt.execute
84
+
85
+ result = con.query('SELECT binary_data FROM blob_table')
86
+ p result.first.first
87
+ end
88
+ end
89
+ ```
data/duckdb.gemspec CHANGED
@@ -26,7 +26,7 @@ Gem::Specification.new do |spec|
26
26
  end
27
27
  spec.require_paths = ['lib']
28
28
  spec.extensions = ['ext/duckdb/extconf.rb']
29
- spec.required_ruby_version = '>= 2.4.0'
29
+ spec.required_ruby_version = '>= 2.5.0'
30
30
 
31
31
  spec.add_development_dependency 'bundler', '~> 2.0'
32
32
  spec.add_development_dependency 'minitest', '~> 5.0'
data/ext/duckdb/blob.c ADDED
@@ -0,0 +1,11 @@
1
+ #include "ruby-duckdb.h"
2
+
3
+ #ifdef HAVE_DUCKDB_VALUE_BLOB
4
+
5
+ VALUE cDuckDBBlob;
6
+
7
+ void init_duckdb_blob(void)
8
+ {
9
+ cDuckDBBlob = rb_define_class_under(mDuckDB, "Blob", rb_cString);
10
+ }
11
+ #endif /* HAVE_DUCKDB_VALUE_BLOB */
data/ext/duckdb/blob.h ADDED
@@ -0,0 +1,14 @@
1
+ #ifndef RUBY_DUCKDB_BLOB_H
2
+ #define RUBY_DUCKDB_BLOB_H
3
+
4
+ /*
5
+ * blob is supported by duckdb v0.2.5 or later
6
+ */
7
+ #ifdef HAVE_DUCKDB_VALUE_BLOB
8
+
9
+ void init_duckdb_blob(void);
10
+
11
+ #endif /* HAVE_DUCKDB_VALUE_BLOB */
12
+
13
+ #endif
14
+
@@ -1,5 +1,7 @@
1
1
  #include "ruby-duckdb.h"
2
2
 
3
+ VALUE cDuckDBConnection;
4
+
3
5
  static void deallocate(void *ctx)
4
6
  {
5
7
  rubyDuckDBConnection *p = (rubyDuckDBConnection *)ctx;
@@ -7,8 +7,6 @@ struct _rubyDuckDBConnection {
7
7
 
8
8
  typedef struct _rubyDuckDBConnection rubyDuckDBConnection;
9
9
 
10
- VALUE cDuckDBConnection;
11
-
12
10
  void init_duckdb_connection(void);
13
11
  VALUE create_connection(VALUE oDuckDBDatabase);
14
12
 
@@ -1,5 +1,7 @@
1
1
  #include "ruby-duckdb.h"
2
2
 
3
+ VALUE cDuckDBDatabase;
4
+
3
5
  static void close_database(rubyDuckDB *p)
4
6
  {
5
7
  duckdb_close(&(p->db));
@@ -7,8 +7,6 @@ struct _rubyDuckDB {
7
7
 
8
8
  typedef struct _rubyDuckDB rubyDuckDB;
9
9
 
10
- VALUE cDuckDBDatabase;
11
-
12
10
  void init_duckdb_database(void);
13
11
 
14
12
  #endif
data/ext/duckdb/duckdb.c CHANGED
@@ -12,4 +12,10 @@ Init_duckdb_native(void)
12
12
  init_duckdb_connection();
13
13
  init_duckdb_result();
14
14
  init_duckdb_prepared_statement();
15
+
16
+ #ifdef HAVE_DUCKDB_VALUE_BLOB
17
+
18
+ init_duckdb_blob();
19
+
20
+ #endif /* HAVE_DUCKDB_VALUE_BLOB */
15
21
  }
data/ext/duckdb/error.c CHANGED
@@ -1,5 +1,7 @@
1
1
  #include "ruby-duckdb.h"
2
2
 
3
+ VALUE eDuckDBError;
4
+
3
5
  void init_duckdb_error(void)
4
6
  {
5
7
  eDuckDBError = rb_define_class_under(mDuckDB, "Error", rb_eStandardError);
data/ext/duckdb/error.h CHANGED
@@ -1,8 +1,6 @@
1
1
  #ifndef RUBY_DUCKDB_ERROR_H
2
2
  #define RUBY_DUCKDB_ERROR_H
3
3
 
4
- VALUE eDuckDBError;
5
-
6
4
  void init_duckdb_error(void);
7
5
 
8
6
  #endif
@@ -2,5 +2,6 @@ require 'mkmf'
2
2
 
3
3
  dir_config('duckdb')
4
4
  if have_library('duckdb')
5
+ have_func('duckdb_value_blob', 'duckdb.h')
5
6
  create_makefile('duckdb/duckdb_native')
6
7
  end
@@ -81,7 +81,7 @@ static VALUE duckdb_prepared_statement_bind_boolean(VALUE self, VALUE vidx, VALU
81
81
  }
82
82
 
83
83
  if (duckdb_bind_boolean(ctx->prepared_statement, idx, (val == Qtrue)) == DuckDBError) {
84
- rb_raise(eDuckDBError, "fail to bind %ld parameter", idx);
84
+ rb_raise(eDuckDBError, "fail to bind %llu parameter", (unsigned long long)idx);
85
85
  }
86
86
  return self;
87
87
  }
@@ -95,7 +95,7 @@ static VALUE duckdb_prepared_statement_bind_int16(VALUE self, VALUE vidx, VALUE
95
95
  Data_Get_Struct(self, rubyDuckDBPreparedStatement, ctx);
96
96
 
97
97
  if (duckdb_bind_int16(ctx->prepared_statement, idx, i16val) == DuckDBError) {
98
- rb_raise(eDuckDBError, "fail to bind %ld parameter", idx);
98
+ rb_raise(eDuckDBError, "fail to bind %llu parameter", (unsigned long long)idx);
99
99
  }
100
100
  return self;
101
101
  }
@@ -104,12 +104,12 @@ static VALUE duckdb_prepared_statement_bind_int32(VALUE self, VALUE vidx, VALUE
104
104
  {
105
105
  rubyDuckDBPreparedStatement *ctx;
106
106
  idx_t idx = check_index(vidx);
107
- int32_t i32val = NUM2LONG(val);
107
+ int32_t i32val = NUM2INT(val);
108
108
 
109
109
  Data_Get_Struct(self, rubyDuckDBPreparedStatement, ctx);
110
110
 
111
111
  if (duckdb_bind_int32(ctx->prepared_statement, idx, i32val) == DuckDBError) {
112
- rb_raise(eDuckDBError, "fail to bind %ld parameter", idx);
112
+ rb_raise(eDuckDBError, "fail to bind %llu parameter", (unsigned long long)idx);
113
113
  }
114
114
  return self;
115
115
  }
@@ -123,7 +123,7 @@ static VALUE duckdb_prepared_statement_bind_int64(VALUE self, VALUE vidx, VALUE
123
123
  Data_Get_Struct(self, rubyDuckDBPreparedStatement, ctx);
124
124
 
125
125
  if (duckdb_bind_int64(ctx->prepared_statement, idx, i64val) == DuckDBError) {
126
- rb_raise(eDuckDBError, "fail to bind %ld parameter", idx);
126
+ rb_raise(eDuckDBError, "fail to bind %llu parameter", (unsigned long long)idx);
127
127
  }
128
128
  return self;
129
129
  }
@@ -137,7 +137,7 @@ static VALUE duckdb_prepared_statement_bind_float(VALUE self, VALUE vidx, VALUE
137
137
  Data_Get_Struct(self, rubyDuckDBPreparedStatement, ctx);
138
138
 
139
139
  if (duckdb_bind_float(ctx->prepared_statement, idx, (float)dbl) == DuckDBError) {
140
- rb_raise(eDuckDBError, "fail to bind %ld parameter", idx);
140
+ rb_raise(eDuckDBError, "fail to bind %llu parameter", (unsigned long long)idx);
141
141
  }
142
142
  return self;
143
143
  }
@@ -151,7 +151,7 @@ static VALUE duckdb_prepared_statement_bind_double(VALUE self, VALUE vidx, VALUE
151
151
  Data_Get_Struct(self, rubyDuckDBPreparedStatement, ctx);
152
152
 
153
153
  if (duckdb_bind_double(ctx->prepared_statement, idx, dbl) == DuckDBError) {
154
- rb_raise(eDuckDBError, "fail to bind %ld parameter", idx);
154
+ rb_raise(eDuckDBError, "fail to bind %llu parameter", (unsigned long long)idx);
155
155
  }
156
156
  return self;
157
157
  }
@@ -163,11 +163,25 @@ static VALUE duckdb_prepared_statement_bind_varchar(VALUE self, VALUE vidx, VALU
163
163
 
164
164
  Data_Get_Struct(self, rubyDuckDBPreparedStatement, ctx);
165
165
  if (duckdb_bind_varchar(ctx->prepared_statement, idx, StringValuePtr(str)) == DuckDBError) {
166
- rb_raise(eDuckDBError, "fail to bind %ld parameter", idx);
166
+ rb_raise(eDuckDBError, "fail to bind %llu parameter", (unsigned long long)idx);
167
167
  }
168
168
  return self;
169
169
  }
170
170
 
171
+ #ifdef HAVE_DUCKDB_VALUE_BLOB
172
+ static VALUE duckdb_prepared_statement_bind_blob(VALUE self, VALUE vidx, VALUE blob)
173
+ {
174
+ rubyDuckDBPreparedStatement *ctx;
175
+ idx_t idx = check_index(vidx);
176
+
177
+ Data_Get_Struct(self, rubyDuckDBPreparedStatement, ctx);
178
+ if (duckdb_bind_blob(ctx->prepared_statement, idx, (const void *)StringValuePtr(blob), (idx_t)RSTRING_LEN(blob)) == DuckDBError) {
179
+ rb_raise(eDuckDBError, "fail to bind %llu parameter", (unsigned long long)idx);
180
+ }
181
+ return self;
182
+ }
183
+ #endif /* HAVE_DUCKDB_VALUE_BLOB */
184
+
171
185
  static VALUE duckdb_prepared_statement_bind_null(VALUE self, VALUE vidx)
172
186
  {
173
187
  rubyDuckDBPreparedStatement *ctx;
@@ -175,7 +189,7 @@ static VALUE duckdb_prepared_statement_bind_null(VALUE self, VALUE vidx)
175
189
 
176
190
  Data_Get_Struct(self, rubyDuckDBPreparedStatement, ctx);
177
191
  if (duckdb_bind_null(ctx->prepared_statement, idx) == DuckDBError) {
178
- rb_raise(eDuckDBError, "fail to bind %ld parameter", idx);
192
+ rb_raise(eDuckDBError, "fail to bind %llu parameter", (unsigned long long)idx);
179
193
  }
180
194
  return self;
181
195
  }
@@ -196,5 +210,8 @@ void init_duckdb_prepared_statement(void)
196
210
  rb_define_method(cDuckDBPreparedStatement, "bind_float", duckdb_prepared_statement_bind_float, 2);
197
211
  rb_define_method(cDuckDBPreparedStatement, "bind_double", duckdb_prepared_statement_bind_double, 2);
198
212
  rb_define_method(cDuckDBPreparedStatement, "bind_varchar", duckdb_prepared_statement_bind_varchar, 2);
213
+ #ifdef HAVE_DUCKDB_VALUE_BLOB
214
+ rb_define_method(cDuckDBPreparedStatement, "bind_blob", duckdb_prepared_statement_bind_blob, 2);
215
+ #endif /* HAVE_DUCKDB_VALUE_BLOB */
199
216
  rb_define_method(cDuckDBPreparedStatement, "bind_null", duckdb_prepared_statement_bind_null, 1);
200
217
  }
data/ext/duckdb/result.c CHANGED
@@ -52,6 +52,14 @@ static VALUE to_ruby_obj_double(duckdb_result *result, idx_t col_idx, idx_t row_
52
52
  return DBL2NUM(dval);
53
53
  }
54
54
 
55
+ #ifdef HAVE_DUCKDB_VALUE_BLOB
56
+ static VALUE to_ruby_obj_string_from_blob(duckdb_result *result, idx_t col_idx, idx_t row_idx)
57
+ {
58
+ duckdb_blob bval = duckdb_value_blob(result, col_idx, row_idx);
59
+ return rb_str_new(bval.data, bval.size);
60
+ }
61
+ #endif /* HAVE_DUCKDB_VALUE_BLOB */
62
+
55
63
  static VALUE to_ruby_obj(duckdb_result *result, idx_t col_idx, idx_t row_idx)
56
64
  {
57
65
  char *p;
@@ -72,6 +80,10 @@ static VALUE to_ruby_obj(duckdb_result *result, idx_t col_idx, idx_t row_idx)
72
80
  return to_ruby_obj_float(result, col_idx, row_idx);
73
81
  case DUCKDB_TYPE_DOUBLE:
74
82
  return to_ruby_obj_double(result, col_idx, row_idx);
83
+ #ifdef HAVE_DUCKDB_VALUE_BLOB
84
+ case DUCKDB_TYPE_BLOB:
85
+ return to_ruby_obj_string_from_blob(result, col_idx, row_idx);
86
+ #endif /* HAVE_DUCKDB_VALUE_BLOB */
75
87
  default:
76
88
  p = duckdb_value_varchar(result, col_idx, row_idx);
77
89
  obj = rb_str_new2(p);
@@ -9,6 +9,22 @@
9
9
  #include "./result.h"
10
10
  #include "./prepared_statement.h"
11
11
 
12
+ #ifdef HAVE_DUCKDB_VALUE_BLOB
13
+
14
+ #include "./blob.h"
15
+
16
+ #endif /* HAVE_DUCKDB_VALUE_BLOB */
17
+
12
18
  extern VALUE mDuckDB;
19
+ extern VALUE cDuckDBDatabase;
20
+ extern VALUE cDuckDBConnection;
21
+
22
+ #ifdef HAVE_DUCKDB_VALUE_BLOB
23
+
24
+ extern VALUE cDuckDBBlob;
25
+
26
+ #endif /* HAVE_DUCKDB_VALUE_BLOB */
27
+
28
+ extern VALUE eDuckDBError;
13
29
 
14
30
  #endif
@@ -33,7 +33,11 @@ module DuckDB
33
33
  when Integer
34
34
  bind_int64(i, value)
35
35
  when String
36
- bind_varchar(i, value)
36
+ if defined?(DuckDB::Blob)
37
+ blob?(value) ? bind_blob(i, value) : bind_varchar(i, value)
38
+ else
39
+ bind_varchar(i, value)
40
+ end
37
41
  when TrueClass, FalseClass
38
42
  bind_boolean(i, value)
39
43
  when Time
@@ -44,5 +48,11 @@ module DuckDB
44
48
  rb_raise(DuckDB::Error, "not supported type #{value} (value.class)")
45
49
  end
46
50
  end
51
+
52
+ private
53
+
54
+ def blob?(value)
55
+ value.instance_of?(DuckDB::Blob) || value.encoding == Encoding::BINARY
56
+ end
47
57
  end
48
58
  end
@@ -1,5 +1,5 @@
1
1
  module DuckDB
2
2
  # The version string of ruby-duckdb.
3
3
  # Currently, ruby-duckdb is NOT semantic versioning.
4
- VERSION = '0.0.8'.freeze
4
+ VERSION = '0.0.12'.freeze
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: duckdb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Masaki Suketa
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-07-04 00:00:00.000000000 Z
11
+ date: 2021-03-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -75,7 +75,8 @@ extensions:
75
75
  - ext/duckdb/extconf.rb
76
76
  extra_rdoc_files: []
77
77
  files:
78
- - ".github/workflows/test_by_github.yml"
78
+ - ".github/workflows/test_on_macos.yml"
79
+ - ".github/workflows/test_on_ubuntu.yml"
79
80
  - ".gitignore"
80
81
  - ".travis.yml"
81
82
  - CHANGELOG.md
@@ -87,6 +88,8 @@ files:
87
88
  - bin/console
88
89
  - bin/setup
89
90
  - duckdb.gemspec
91
+ - ext/duckdb/blob.c
92
+ - ext/duckdb/blob.h
90
93
  - ext/duckdb/connection.c
91
94
  - ext/duckdb/connection.h
92
95
  - ext/duckdb/database.c
@@ -121,14 +124,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
121
124
  requirements:
122
125
  - - ">="
123
126
  - !ruby/object:Gem::Version
124
- version: 2.4.0
127
+ version: 2.5.0
125
128
  required_rubygems_version: !ruby/object:Gem::Requirement
126
129
  requirements:
127
130
  - - ">="
128
131
  - !ruby/object:Gem::Version
129
132
  version: '0'
130
133
  requirements: []
131
- rubygems_version: 3.1.2
134
+ rubygems_version: 3.2.3
132
135
  signing_key:
133
136
  specification_version: 4
134
137
  summary: This module is Ruby binding for DuckDB database engine.
@@ -1,66 +0,0 @@
1
- name: Ubuntu
2
-
3
- on: [push]
4
-
5
- jobs:
6
- build:
7
-
8
- runs-on: ubuntu-latest
9
- strategy:
10
- matrix:
11
- ruby: ['2.5.8', '2.6.6', '2.7.1', 'head']
12
- duckdb: ['0.1.8', '0.1.9']
13
-
14
- steps:
15
- - uses: actions/checkout@v2
16
-
17
- - name: Set up Ruby
18
- uses: ruby/setup-ruby@v1
19
- with:
20
- ruby-version: ${{ matrix.ruby }}
21
-
22
- - name: duckdb 0.1.8 cache
23
- id: duckdb-cache-v0_1_8
24
- uses: actions/cache@v1.1.0
25
- with:
26
- path: duckdb-v0.1.8
27
- key: ${{ runner.os }}-duckdb-v0_1_8_001
28
- restore-keys: |
29
- ${{ runner.os }}-duckdb-v0_1_8
30
-
31
- - name: duckdb 0.1.9 cache
32
- id: duckdb-cache-v0_1_9
33
- uses: actions/cache@v1.1.0
34
- with:
35
- path: duckdb-v0.1.9
36
- key: ${{ runner.os }}-duckdb-v0_1_9_001
37
- restore-keys: |
38
- ${{ runner.os }}-duckdb-v0_1_9
39
-
40
- - name: Build duckdb 0.1.8
41
- if: steps.duckdb-cache-v0_1_8.outputs.cache-hit != 'true'
42
- run: |
43
- git clone -b v0.1.8 https://github.com/cwida/duckdb.git duckdb-tmp-v0.1.8
44
- cd duckdb-tmp-v0.1.8 && make && cd ..
45
- rm -rf duckdb-v0.1.8
46
- mkdir -p duckdb-v0.1.8/build/release/src duckdb-v0.1.8/src
47
- cp -rip duckdb-tmp-v0.1.8/build/release/src/*.so duckdb-v0.1.8/build/release/src
48
- cp -rip duckdb-tmp-v0.1.8/src/include duckdb-v0.1.8/src/
49
-
50
- - name: Build duckdb 0.1.9
51
- if: steps.duckdb-cache-v0_1_9.outputs.cache-hit != 'true'
52
- run: |
53
- git clone -b v0.1.9 https://github.com/cwida/duckdb.git duckdb-tmp-v0.1.9
54
- cd duckdb-tmp-v0.1.9 && make && cd ..
55
- rm -rf duckdb-v0.1.9
56
- mkdir -p duckdb-v0.1.9/build/release/src duckdb-v0.1.9/src
57
- cp -rip duckdb-tmp-v0.1.9/build/release/src/*.so duckdb-v0.1.9/build/release/src
58
- cp -rip duckdb-tmp-v0.1.9/src/include duckdb-v0.1.9/src/
59
-
60
- - name: Build and test with Rake with Ruby ${{ matrix.ruby }}
61
- env:
62
- DUCKDB_VERSION: ${{ matrix.duckdb }}
63
- run: |
64
- gem install bundler
65
- bundle install --jobs 4 --retry 3
66
- bundle exec rake -- --with-duckdb-include=${GITHUB_WORKSPACE}/duckdb-v${DUCKDB_VERSION}/src/include --with-duckdb-lib=${GITHUB_WORKSPACE}/duckdb-v${DUCKDB_VERSION}/build/release/src/