duckdb 0.0.4 → 0.0.5
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 +4 -4
- data/CHANGELOG.md +12 -1
- data/Gemfile.lock +1 -1
- data/duckdb.gemspec +2 -2
- data/ext/duckdb/connection.c +2 -2
- data/ext/duckdb/database.c +1 -1
- data/ext/duckdb/duckdb.c +1 -0
- data/ext/duckdb/error.c +5 -0
- data/ext/duckdb/error.h +10 -0
- data/ext/duckdb/result.c +66 -5
- data/ext/duckdb/ruby-duckdb.h +1 -0
- data/lib/duckdb.rb +3 -2
- data/lib/duckdb/result.rb +5 -0
- data/lib/duckdb/version.rb +1 -1
- metadata +7 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 599ebecd3f693be06ff46fec535485d6ac6019cd889405a502d21a2f801c9ba8
|
4
|
+
data.tar.gz: '0811911b5f0c3404f8c7ff9c2351d97668013dd576d4f5a98775e9af45df5e52'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b4ca8e956de0edbb9aa9ceed9273a48f3cf847e5ff79732b849465c59fa2030af5cd81c62344e953e96990e11c48ff1b2dd8bd3cd87f3bc8271079aeb69a31bd
|
7
|
+
data.tar.gz: 3501865c8c0aa7c70761705e06026aadd95e112d34fd9eed1152ae269407fddc7cdbe6a84f6f3f8cda917022bda45fb0d349b51400b939f43b74ae64bb8e43bf
|
data/CHANGELOG.md
CHANGED
@@ -1,8 +1,19 @@
|
|
1
1
|
# ChangeLog
|
2
2
|
|
3
|
+
## 0.0.5
|
4
|
+
|
5
|
+
- add `DuckDB::Error`
|
6
|
+
- `DuckDB::Result#each` convert DuckDB number value to Ruby's number
|
7
|
+
- `DuckDB::Result#each` convert DuckDB NULL value to nil
|
8
|
+
- `DuckDB::Result#each` returns Enumerator object when block is not given
|
9
|
+
- `DuckDB::Result` include `Enumerable`
|
10
|
+
- add test for `DuckDB::Result`
|
11
|
+
- add test for `DuckDB::Connection`
|
12
|
+
- fix description in duckdb.gemspec
|
13
|
+
|
3
14
|
## 0.0.4
|
4
15
|
|
5
|
-
- add
|
16
|
+
- add test for `DuckDB::Database`
|
6
17
|
- rename module name to `DuckDB` from `Duckdb`
|
7
18
|
|
8
19
|
## 0.0.3
|
data/Gemfile.lock
CHANGED
data/duckdb.gemspec
CHANGED
@@ -9,13 +9,13 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.email = ["masaki.suketa@nifty.ne.jp"]
|
10
10
|
|
11
11
|
spec.summary = %q{This module is Ruby binding for DuckDB database engine.}
|
12
|
-
spec.description =
|
12
|
+
spec.description = "This module is Ruby binding for DuckDB database engine. You must have the DuckDB engine installed to build/use this module."
|
13
13
|
spec.homepage = "https://github.com/suketa/ruby-duckdb"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
16
16
|
spec.metadata["homepage_uri"] = spec.homepage
|
17
17
|
spec.metadata["source_code_uri"] = "https://github.com/suketa/ruby-duckdb"
|
18
|
-
spec.metadata["changelog_uri"] = "https://github.com/suketa/ruby-duckdb/CHANGELOG.md"
|
18
|
+
spec.metadata["changelog_uri"] = "https://github.com/suketa/ruby-duckdb/blob/master/CHANGELOG.md"
|
19
19
|
|
20
20
|
# Specify which files should be added to the gem when it is released.
|
21
21
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
data/ext/duckdb/connection.c
CHANGED
@@ -27,7 +27,7 @@ VALUE create_connection(VALUE oDuckDBDatabase) {
|
|
27
27
|
Data_Get_Struct(obj, rubyDuckDBConnection, ctxcon);
|
28
28
|
|
29
29
|
if (duckdb_connect(ctxdb->db, &(ctxcon->con)) == DuckDBError) {
|
30
|
-
rb_raise(
|
30
|
+
rb_raise(eDuckDBError, "connection error");
|
31
31
|
}
|
32
32
|
|
33
33
|
// rb_ivar_set(obj, rb_intern("database"), oDuckDBDatabase);
|
@@ -45,7 +45,7 @@ static VALUE duckdb_connection_query(VALUE self, VALUE str) {
|
|
45
45
|
Data_Get_Struct(result, rubyDuckDBResult, ctxr);
|
46
46
|
|
47
47
|
if (duckdb_query(ctx->con, StringValueCStr(str), &(ctxr->result)) == DuckDBError) {
|
48
|
-
rb_raise(
|
48
|
+
rb_raise(eDuckDBError, "%s", ctxr->result.error_message);
|
49
49
|
}
|
50
50
|
return result;
|
51
51
|
}
|
data/ext/duckdb/database.c
CHANGED
@@ -31,7 +31,7 @@ static VALUE duckdb_database_s_open(int argc, VALUE *argv, VALUE cDuckDBDatabase
|
|
31
31
|
Data_Get_Struct(obj, rubyDuckDB, ctx);
|
32
32
|
if (duckdb_open(pfile, &(ctx->db)) == DuckDBError)
|
33
33
|
{
|
34
|
-
rb_raise(
|
34
|
+
rb_raise(eDuckDBError, "Failed to open database"); /* FIXME */
|
35
35
|
}
|
36
36
|
return obj;
|
37
37
|
}
|
data/ext/duckdb/duckdb.c
CHANGED
data/ext/duckdb/error.c
ADDED
data/ext/duckdb/error.h
ADDED
data/ext/duckdb/result.c
CHANGED
@@ -16,23 +16,84 @@ static VALUE allocate(VALUE klass)
|
|
16
16
|
return Data_Wrap_Struct(klass, NULL, deallocate, ctx);
|
17
17
|
}
|
18
18
|
|
19
|
+
static VALUE to_ruby_obj_boolean(duckdb_result *result, size_t col_idx, size_t row_idx) {
|
20
|
+
bool bval = duckdb_value_boolean(result, col_idx, row_idx);
|
21
|
+
return bval ? Qtrue : Qnil;
|
22
|
+
}
|
23
|
+
|
24
|
+
static VALUE to_ruby_obj_smallint(duckdb_result *result, size_t col_idx, size_t row_idx) {
|
25
|
+
int16_t i16val = duckdb_value_int16(result, col_idx, row_idx);
|
26
|
+
return INT2FIX(i16val);
|
27
|
+
}
|
28
|
+
|
29
|
+
static VALUE to_ruby_obj_integer(duckdb_result *result, size_t col_idx, size_t row_idx) {
|
30
|
+
int32_t i32val = duckdb_value_int32(result, col_idx, row_idx);
|
31
|
+
return INT2NUM(i32val);
|
32
|
+
}
|
33
|
+
|
34
|
+
static VALUE to_ruby_obj_bigint(duckdb_result *result, size_t col_idx, size_t row_idx) {
|
35
|
+
int64_t i64val = duckdb_value_int64(result, col_idx, row_idx);
|
36
|
+
return rb_int2big(i64val);
|
37
|
+
}
|
38
|
+
|
39
|
+
static VALUE to_ruby_obj_float(duckdb_result *result, size_t col_idx, size_t row_idx) {
|
40
|
+
float fval = duckdb_value_float(result, col_idx, row_idx);
|
41
|
+
return DBL2NUM(fval);
|
42
|
+
}
|
43
|
+
|
44
|
+
static VALUE to_ruby_obj_double(duckdb_result *result, size_t col_idx, size_t row_idx) {
|
45
|
+
double dval = duckdb_value_double(result, col_idx, row_idx);
|
46
|
+
return DBL2NUM(dval);
|
47
|
+
}
|
48
|
+
|
49
|
+
static VALUE to_ruby_obj(duckdb_result *result, size_t col_idx, size_t row_idx) {
|
50
|
+
char *p;
|
51
|
+
VALUE obj = Qnil;
|
52
|
+
if (result->columns[col_idx].nullmask[row_idx]) {
|
53
|
+
return obj;
|
54
|
+
}
|
55
|
+
switch(result->columns[col_idx].type) {
|
56
|
+
case DUCKDB_TYPE_BOOLEAN:
|
57
|
+
return to_ruby_obj_boolean(result, col_idx, row_idx);
|
58
|
+
case DUCKDB_TYPE_SMALLINT:
|
59
|
+
return to_ruby_obj_smallint(result, col_idx, row_idx);
|
60
|
+
case DUCKDB_TYPE_INTEGER:
|
61
|
+
return to_ruby_obj_integer(result, col_idx, row_idx);
|
62
|
+
case DUCKDB_TYPE_BIGINT:
|
63
|
+
return to_ruby_obj_bigint(result, col_idx, row_idx);
|
64
|
+
case DUCKDB_TYPE_FLOAT:
|
65
|
+
return to_ruby_obj_float(result, col_idx, row_idx);
|
66
|
+
case DUCKDB_TYPE_DOUBLE:
|
67
|
+
return to_ruby_obj_double(result, col_idx, row_idx);
|
68
|
+
default:
|
69
|
+
p = duckdb_value_varchar(result, col_idx, row_idx);
|
70
|
+
obj = rb_str_new2(p);
|
71
|
+
free(p);
|
72
|
+
}
|
73
|
+
return obj;
|
74
|
+
}
|
75
|
+
|
19
76
|
static VALUE row_array(rubyDuckDBResult *ctx, size_t row_idx) {
|
20
77
|
size_t col_idx;
|
21
78
|
VALUE ary = rb_ary_new2(ctx->result.column_count);
|
22
79
|
for(col_idx = 0; col_idx < ctx->result.column_count; col_idx++) {
|
23
|
-
|
24
|
-
rb_ary_store(ary, col_idx, rb_str_new2(p));
|
25
|
-
|
26
|
-
free(p);
|
80
|
+
rb_ary_store(ary, col_idx, to_ruby_obj(&(ctx->result), col_idx, row_idx));
|
27
81
|
}
|
28
82
|
return ary;
|
29
83
|
}
|
30
84
|
|
85
|
+
static VALUE duckdb_result_row_size(VALUE oDuckDBResult, VALUE args, VALUE obj) {
|
86
|
+
rubyDuckDBResult *ctx;
|
87
|
+
Data_Get_Struct(oDuckDBResult, rubyDuckDBResult, ctx);
|
88
|
+
|
89
|
+
return LONG2FIX(ctx->result.row_count);
|
90
|
+
}
|
91
|
+
|
31
92
|
static VALUE duckdb_result_each(VALUE oDuckDBResult) {
|
32
93
|
rubyDuckDBResult *ctx;
|
33
94
|
size_t row_idx = 0;
|
34
95
|
|
35
|
-
|
96
|
+
RETURN_SIZED_ENUMERATOR(oDuckDBResult, 0, 0, duckdb_result_row_size);
|
36
97
|
|
37
98
|
Data_Get_Struct(oDuckDBResult, rubyDuckDBResult, ctx);
|
38
99
|
for (row_idx = 0; row_idx < ctx->result.row_count; row_idx++) {
|
data/ext/duckdb/ruby-duckdb.h
CHANGED
data/lib/duckdb.rb
CHANGED
data/lib/duckdb/version.rb
CHANGED
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.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Masaki Suketa
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-11-
|
11
|
+
date: 2019-11-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -66,7 +66,7 @@ dependencies:
|
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '5.0'
|
69
|
-
description: This module is Ruby binding for DuckDB database engine
|
69
|
+
description: This module is Ruby binding for DuckDB database engine. You must have
|
70
70
|
the DuckDB engine installed to build/use this module.
|
71
71
|
email:
|
72
72
|
- masaki.suketa@nifty.ne.jp
|
@@ -91,11 +91,14 @@ files:
|
|
91
91
|
- ext/duckdb/database.c
|
92
92
|
- ext/duckdb/database.h
|
93
93
|
- ext/duckdb/duckdb.c
|
94
|
+
- ext/duckdb/error.c
|
95
|
+
- ext/duckdb/error.h
|
94
96
|
- ext/duckdb/extconf.rb
|
95
97
|
- ext/duckdb/result.c
|
96
98
|
- ext/duckdb/result.h
|
97
99
|
- ext/duckdb/ruby-duckdb.h
|
98
100
|
- lib/duckdb.rb
|
101
|
+
- lib/duckdb/result.rb
|
99
102
|
- lib/duckdb/version.rb
|
100
103
|
homepage: https://github.com/suketa/ruby-duckdb
|
101
104
|
licenses:
|
@@ -103,7 +106,7 @@ licenses:
|
|
103
106
|
metadata:
|
104
107
|
homepage_uri: https://github.com/suketa/ruby-duckdb
|
105
108
|
source_code_uri: https://github.com/suketa/ruby-duckdb
|
106
|
-
changelog_uri: https://github.com/suketa/ruby-duckdb/CHANGELOG.md
|
109
|
+
changelog_uri: https://github.com/suketa/ruby-duckdb/blob/master/CHANGELOG.md
|
107
110
|
post_install_message:
|
108
111
|
rdoc_options: []
|
109
112
|
require_paths:
|