duckdb 0.3.2-dev706.0 → 0.3.2-dev709.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.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "duckdb",
3
3
  "main": "./lib/duckdb.js",
4
- "version": "0.3.2-dev706.0",
4
+ "version": "0.3.2-dev709.0",
5
5
  "description": "DuckDB node.js API",
6
6
  "gypfile": true,
7
7
  "dependencies": {
package/src/duckdb.hpp CHANGED
@@ -10,8 +10,8 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
10
10
 
11
11
  #pragma once
12
12
  #define DUCKDB_AMALGAMATION 1
13
- #define DUCKDB_SOURCE_ID "18b71004d"
14
- #define DUCKDB_VERSION "0.3.2-dev706"
13
+ #define DUCKDB_SOURCE_ID "0cb16079e"
14
+ #define DUCKDB_VERSION "0.3.2-dev709"
15
15
  //===----------------------------------------------------------------------===//
16
16
  // DuckDB
17
17
  //
package/src/statement.cpp CHANGED
@@ -135,6 +135,10 @@ static Napi::Value convert_chunk(Napi::Env &env, std::vector<std::string> names,
135
135
 
136
136
  for (duckdb::idx_t col_idx = 0; col_idx < chunk.ColumnCount(); col_idx++) {
137
137
  Napi::Value value;
138
+ // set up a new Napi::Object for some data types, e.g. INTERVAL
139
+ Napi::Object object_value;
140
+
141
+ bool is_object_value {false};
138
142
 
139
143
  auto dval = chunk.GetValue(col_idx, row_idx);
140
144
  if (dval.is_null) {
@@ -159,6 +163,13 @@ static Napi::Value convert_chunk(Napi::Env &env, std::vector<std::string> names,
159
163
  case duckdb::LogicalTypeId::HUGEINT: {
160
164
  value = Napi::Number::New(env, dval.GetValue<double>());
161
165
  } break;
166
+ case duckdb::LogicalTypeId::INTERVAL: {
167
+ is_object_value = true;
168
+ object_value = Napi::Object::New(env);
169
+ object_value.Set("months", dval.value_.interval.months);
170
+ object_value.Set("days", dval.value_.interval.days);
171
+ object_value.Set("micros", dval.value_.interval.micros);
172
+ } break;
162
173
  #if (NAPI_VERSION > 4)
163
174
  case duckdb::LogicalTypeId::DATE: {
164
175
  const auto scale = duckdb::Interval::SECS_PER_DAY * duckdb::Interval::MSECS_PER_SEC;
@@ -185,7 +196,11 @@ static Napi::Value convert_chunk(Napi::Env &env, std::vector<std::string> names,
185
196
  .ThrowAsJavaScriptException();
186
197
  return env.Null();
187
198
  }
188
- row_result.Set(node_names[col_idx], value);
199
+ if (is_object_value == true) {
200
+ row_result.Set(node_names[col_idx], object_value);
201
+ } else {
202
+ row_result.Set(node_names[col_idx], value);
203
+ }
189
204
  }
190
205
  result.Set(row_idx, row_result);
191
206
  }
@@ -20,4 +20,18 @@ describe("data type support", function () {
20
20
  done();
21
21
  });
22
22
  });
23
+ it("supports INTERVAL values", function (done) {
24
+ db.prepare(`SELECT
25
+ INTERVAL 1 MINUTE as minutes,
26
+ INTERVAL 5 DAY as days,
27
+ INTERVAL 4 MONTH as months,
28
+ INTERVAL 4 MONTH + INTERVAL 5 DAY + INTERVAL 1 MINUTE as combined;`).each((err, row) => {
29
+ assert(err === null);
30
+ assert.deepEqual(row.minutes, { months: 0, days: 0, micros: 60 * 1000 * 1000});
31
+ assert.deepEqual(row.days, { months: 0, days: 5, micros: 0});
32
+ assert.deepEqual(row.months, {months: 4, days: 0, micros: 0});
33
+ assert.deepEqual(row.combined, {months: 4, days: 5, micros: 60 * 1000 * 1000});
34
+ done();
35
+ });
36
+ });
23
37
  });