duckdb 1.1.2.1 → 1.1.3.0

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: f326104e9d96a1fce6a508d481101c37eca2b12a421eb2ddb07acb838f14c118
4
- data.tar.gz: 999db21104bb772564ecb41bbc2fee06d728f65618bb8538d14bc20c22173424
3
+ metadata.gz: 5d9c9c9844335a39c1c154534cb50c031f872679c98eb5434a9d664805091c96
4
+ data.tar.gz: ca48e19a321441194515ad781ebcedb5010bca519e53bdfe9469af6a83add301
5
5
  SHA512:
6
- metadata.gz: 6cb7f30f39a2b768d1d6441e324f2c86f910f7af2cff9ca403b91eeb13cacbc0bee56dc54d3786f58e27af9276ae91d4a2ce22c705727b0c8ef5cd3251ab83fe
7
- data.tar.gz: f17ea13a5aca9640e17e8983a37f9ba88e6ace381d5ad7e979232b0158028b92aa07ddea758ffdd9868511fb2b868354f7f15c20d6c14fb4f2e537613f8ee670
6
+ metadata.gz: 2fa6587abdac4d639630c0a605704ed76ff5f3373dcf56f83355dcc999913689e6628db690b8004ccdfc510ade6440b7ca088d9e9ac3a71e228a68ce2a8b359f
7
+ data.tar.gz: 1776ead93436933f732ec46c573ef7ef056c2cb86b9d601ac6574cf252c0a9774a3f78b464ddb8fe32deb61d5f626f4e6a379276898d08176a429def29f90a10
@@ -15,8 +15,8 @@ jobs:
15
15
  runs-on: macos-latest
16
16
  strategy:
17
17
  matrix:
18
- ruby: ['3.1.6', '3.2.5', '3.3.5', '3.4.0-preview2', 'head']
19
- duckdb: ['1.1.2', '1.1.1', '1.0.0']
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']
20
20
 
21
21
  steps:
22
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.5', '3.3.5', '3.4.0-preview2', 'head']
19
- duckdb: ['1.1.2', '1.1.1', '1.0.0']
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']
20
20
 
21
21
  steps:
22
22
  - uses: actions/checkout@v4
@@ -16,7 +16,7 @@ jobs:
16
16
  strategy:
17
17
  matrix:
18
18
  ruby: ['3.1.6', '3.2.5', '3.3.5', 'ucrt', 'mingw', 'mswin', 'head']
19
- duckdb: ['1.1.2', '1.1.1', '1.0.0']
19
+ duckdb: ['1.1.3', '1.1.1', '1.0.0']
20
20
 
21
21
  steps:
22
22
  - uses: actions/checkout@v4
data/CHANGELOG.md CHANGED
@@ -3,6 +3,10 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  # Unreleased
5
5
 
6
+ # 1.1.3.0 - 2024-11-10
7
+ - add `DuckDB::PreparedStatement#bind_decimal`. (Thanks to @otegami)
8
+ - bump duckdb to 1.1.3.
9
+
6
10
  # 1.1.2.1 - 2024-11-04
7
11
  - `DuckDB::Connection#query` accepts multiple SQL statement.
8
12
  - When multiple SQL statements are given, `DuckDB::Connection#query` returns the last statement result.
data/Dockerfile CHANGED
@@ -1,7 +1,7 @@
1
- ARG RUBY_VERSION=3.3.5
1
+ ARG RUBY_VERSION=3.3.6
2
2
  FROM ruby:${RUBY_VERSION}
3
3
 
4
- ARG DUCKDB_VERSION=1.1.2
4
+ ARG DUCKDB_VERSION=1.1.3
5
5
 
6
6
  RUN apt update -qq && \
7
7
  apt install -y build-essential curl git wget
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- duckdb (1.1.2.1)
4
+ duckdb (1.1.3.0)
5
5
  bigdecimal (>= 3.1.4)
6
6
 
7
7
  GEM
@@ -81,7 +81,6 @@ static VALUE duckdb_extracted_statements_size(VALUE self) {
81
81
  return ULL2NUM(ctx->num_statements);
82
82
  }
83
83
 
84
-
85
84
  static VALUE duckdb_extracted_statements_prepared_statement(VALUE self, VALUE con, VALUE index) {
86
85
  rubyDuckDBConnection *pcon;
87
86
  rubyDuckDBExtractedStatements *ctx;
@@ -155,6 +155,19 @@ module DuckDB
155
155
  end
156
156
  end
157
157
 
158
+ def _parse_deciaml(value)
159
+ case value
160
+ when BigDecimal
161
+ value
162
+ else
163
+ begin
164
+ BigDecimal(value.to_s)
165
+ rescue StandardError => e
166
+ raise(ArgumentError, "Cannot parse `#{value.inspect}` to BigDecimal object. #{e.message}")
167
+ end
168
+ end
169
+ end
170
+
158
171
  def _to_query_progress(percentage, rows_processed, total_rows_to_process)
159
172
  DuckDB::QueryProgress.new(percentage, rows_processed, total_rows_to_process).freeze
160
173
  end
@@ -171,5 +184,12 @@ module DuckDB
171
184
  raise(ArgumentError, "The argument `#{value.inspect}` must be Integer.")
172
185
  end
173
186
  end
187
+
188
+ def decimal_to_hugeint(value)
189
+ integer_value = (value * (10 ** value.scale)).to_i
190
+ integer_to_hugeint(integer_value)
191
+ rescue FloatDomainError => e
192
+ raise(ArgumentError, "The argument `#{value.inspect}` must be converted to Integer. #{e.message}")
193
+ end
174
194
  end
175
195
  end
@@ -216,6 +216,25 @@ module DuckDB
216
216
  _bind_interval(index, value.interval_months, value.interval_days, value.interval_micros)
217
217
  end
218
218
 
219
+ # binds i-th parameter with SQL prepared statement.
220
+ # The first argument is index of parameter.
221
+ # The index of first parameter is 1 not 0.
222
+ # The second argument value is to expected BigDecimal value or any value
223
+ # that can be parsed into a BigDecimal.
224
+ #
225
+ # require 'duckdb'
226
+ # db = DuckDB::Database.open('duckdb_database')
227
+ # con = db.connect
228
+ # sql ='SELECT value FROM decimals WHERE decimal = ?'
229
+ # stmt = PreparedStatement.new(con, sql)
230
+ # stmt.bind_decimal(1, BigDecimal('987654.321'))
231
+ def bind_decimal(index, value)
232
+ decimal = _parse_deciaml(value)
233
+ lower, upper = decimal_to_hugeint(decimal)
234
+ width = decimal.to_s('F').gsub(/[^0-9]/, '').length
235
+ _bind_decimal(index, lower, upper, width, decimal.scale)
236
+ end
237
+
219
238
  # binds i-th parameter with SQL prepared statement.
220
239
  # The first argument is index of parameter.
221
240
  # The index of first parameter is 1 not 0.
@@ -264,7 +283,7 @@ module DuckDB
264
283
  when Date
265
284
  bind_varchar(index, value.strftime('%Y-%m-%d'))
266
285
  when BigDecimal
267
- bind_varchar(index, value.to_s('F'))
286
+ bind_decimal(index, value)
268
287
  else
269
288
  raise(DuckDB::Error, "not supported type `#{value}` (#{value.class})")
270
289
  end
@@ -3,5 +3,5 @@
3
3
  module DuckDB
4
4
  # The version string of ruby-duckdb.
5
5
  # Currently, ruby-duckdb is NOT semantic versioning.
6
- VERSION = '1.1.2.1'
6
+ VERSION = '1.1.3.0'
7
7
  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: 1.1.2.1
4
+ version: 1.1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Masaki Suketa
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-11-04 00:00:00.000000000 Z
11
+ date: 2024-11-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bigdecimal