@duckdb/node-api 1.3.4-alpha.27 → 1.4.0-r.2
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/lib/DuckDBAppender.d.ts +1 -1
- package/lib/DuckDBAppender.js +2 -2
- package/lib/DuckDBLogicalType.js +2 -2
- package/lib/DuckDBPreparedStatement.d.ts +1 -1
- package/lib/DuckDBPreparedStatement.js +2 -2
- package/lib/DuckDBResult.d.ts +9 -0
- package/lib/DuckDBResult.js +45 -0
- package/lib/DuckDBType.d.ts +5 -5
- package/lib/DuckDBType.js +9 -9
- package/lib/DuckDBTypeId.d.ts +1 -1
- package/lib/DuckDBTypeId.js +1 -1
- package/lib/DuckDBVector.d.ts +5 -5
- package/lib/DuckDBVector.js +21 -21
- package/lib/JSDuckDBValueConverter.js +1 -1
- package/lib/JsonDuckDBValueConverter.js +1 -1
- package/lib/createValue.js +2 -2
- package/lib/sql.js +2 -2
- package/package.json +2 -2
package/lib/DuckDBAppender.d.ts
CHANGED
|
@@ -44,7 +44,7 @@ export declare class DuckDBAppender {
|
|
|
44
44
|
appendUnion(value: DuckDBUnionValue, type?: DuckDBUnionType): void;
|
|
45
45
|
appendUUID(value: DuckDBUUIDValue): void;
|
|
46
46
|
appendBit(value: DuckDBBitValue): void;
|
|
47
|
-
|
|
47
|
+
appendBigNum(value: bigint): void;
|
|
48
48
|
appendNull(): void;
|
|
49
49
|
appendValue(value: DuckDBValue, type?: DuckDBType): void;
|
|
50
50
|
appendDataChunk(dataChunk: DuckDBDataChunk): void;
|
package/lib/DuckDBAppender.js
CHANGED
|
@@ -133,8 +133,8 @@ class DuckDBAppender {
|
|
|
133
133
|
appendBit(value) {
|
|
134
134
|
this.appendValue(value, DuckDBType_1.BIT);
|
|
135
135
|
}
|
|
136
|
-
|
|
137
|
-
this.appendValue(value, DuckDBType_1.
|
|
136
|
+
appendBigNum(value) {
|
|
137
|
+
this.appendValue(value, DuckDBType_1.BIGNUM);
|
|
138
138
|
}
|
|
139
139
|
appendNull() {
|
|
140
140
|
node_bindings_1.default.append_null(this.appender);
|
package/lib/DuckDBLogicalType.js
CHANGED
|
@@ -155,8 +155,8 @@ class DuckDBLogicalType {
|
|
|
155
155
|
return DuckDBType_1.DuckDBTimestampTZType.create(alias);
|
|
156
156
|
case DuckDBTypeId_1.DuckDBTypeId.ANY:
|
|
157
157
|
return DuckDBType_1.DuckDBAnyType.create(alias);
|
|
158
|
-
case DuckDBTypeId_1.DuckDBTypeId.
|
|
159
|
-
return DuckDBType_1.
|
|
158
|
+
case DuckDBTypeId_1.DuckDBTypeId.BIGNUM:
|
|
159
|
+
return DuckDBType_1.DuckDBBigNumType.create(alias);
|
|
160
160
|
case DuckDBTypeId_1.DuckDBTypeId.SQLNULL:
|
|
161
161
|
return DuckDBType_1.DuckDBSQLNullType.create(alias);
|
|
162
162
|
default:
|
|
@@ -29,7 +29,7 @@ export declare class DuckDBPreparedStatement {
|
|
|
29
29
|
bindUInteger(parameterIndex: number, value: number): void;
|
|
30
30
|
bindUBigInt(parameterIndex: number, value: bigint): void;
|
|
31
31
|
bindUHugeInt(parameterIndex: number, value: bigint): void;
|
|
32
|
-
|
|
32
|
+
bindBigNum(parameterIndex: number, value: bigint): void;
|
|
33
33
|
bindDecimal(parameterIndex: number, value: DuckDBDecimalValue): void;
|
|
34
34
|
bindFloat(parameterIndex: number, value: number): void;
|
|
35
35
|
bindDouble(parameterIndex: number, value: number): void;
|
|
@@ -76,8 +76,8 @@ class DuckDBPreparedStatement {
|
|
|
76
76
|
bindUHugeInt(parameterIndex, value) {
|
|
77
77
|
node_bindings_1.default.bind_uhugeint(this.prepared_statement, parameterIndex, value);
|
|
78
78
|
}
|
|
79
|
-
|
|
80
|
-
this.bindValue(parameterIndex, value, DuckDBType_1.
|
|
79
|
+
bindBigNum(parameterIndex, value) {
|
|
80
|
+
this.bindValue(parameterIndex, value, DuckDBType_1.BIGNUM);
|
|
81
81
|
}
|
|
82
82
|
bindDecimal(parameterIndex, value) {
|
|
83
83
|
node_bindings_1.default.bind_decimal(this.prepared_statement, parameterIndex, value);
|
package/lib/DuckDBResult.d.ts
CHANGED
|
@@ -45,4 +45,13 @@ export declare class DuckDBResult {
|
|
|
45
45
|
convertRowObjects<T>(converter: DuckDBValueConverter<T>): Promise<Record<string, T | null>[]>;
|
|
46
46
|
getRowObjectsJS(): Promise<Record<string, JS>[]>;
|
|
47
47
|
getRowObjectsJson(): Promise<Record<string, Json>[]>;
|
|
48
|
+
[Symbol.asyncIterator](): AsyncIterableIterator<DuckDBDataChunk>;
|
|
49
|
+
yieldRows(): AsyncIterableIterator<DuckDBValue[][]>;
|
|
50
|
+
yieldRowObjects(): AsyncIterableIterator<Record<string, DuckDBValue>[]>;
|
|
51
|
+
yieldConvertedRows<T>(converter: DuckDBValueConverter<T>): AsyncIterableIterator<(T | null)[][]>;
|
|
52
|
+
yieldConvertedRowObjects<T>(converter: DuckDBValueConverter<T>): AsyncIterableIterator<Record<string, T | null>[]>;
|
|
53
|
+
yieldRowsJs(): AsyncIterableIterator<JS[][]>;
|
|
54
|
+
yieldRowsJson(): AsyncIterableIterator<Json[][]>;
|
|
55
|
+
yieldRowObjectJs(): AsyncIterableIterator<Record<string, JS>[]>;
|
|
56
|
+
yieldRowObjectJson(): AsyncIterableIterator<Record<string, Json>[]>;
|
|
48
57
|
}
|
package/lib/DuckDBResult.js
CHANGED
|
@@ -180,5 +180,50 @@ class DuckDBResult {
|
|
|
180
180
|
async getRowObjectsJson() {
|
|
181
181
|
return this.convertRowObjects(JsonDuckDBValueConverter_1.JsonDuckDBValueConverter);
|
|
182
182
|
}
|
|
183
|
+
async *[Symbol.asyncIterator]() {
|
|
184
|
+
while (true) {
|
|
185
|
+
const chunk = await this.fetchChunk();
|
|
186
|
+
if (chunk && chunk.rowCount > 0) {
|
|
187
|
+
yield chunk;
|
|
188
|
+
}
|
|
189
|
+
else {
|
|
190
|
+
break;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
async *yieldRows() {
|
|
195
|
+
for await (const chunk of this) {
|
|
196
|
+
yield (0, getRowsFromChunks_1.getRowsFromChunks)([chunk]);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
async *yieldRowObjects() {
|
|
200
|
+
const deduplicatedColumnNames = this.deduplicatedColumnNames();
|
|
201
|
+
for await (const chunk of this) {
|
|
202
|
+
yield (0, getRowObjectsFromChunks_1.getRowObjectsFromChunks)([chunk], deduplicatedColumnNames);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
async *yieldConvertedRows(converter) {
|
|
206
|
+
for await (const chunk of this) {
|
|
207
|
+
yield (0, convertRowsFromChunks_1.convertRowsFromChunks)([chunk], converter);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
async *yieldConvertedRowObjects(converter) {
|
|
211
|
+
const deduplicatedColumnNames = this.deduplicatedColumnNames();
|
|
212
|
+
for await (const chunk of this) {
|
|
213
|
+
yield (0, convertRowObjectsFromChunks_1.convertRowObjectsFromChunks)([chunk], deduplicatedColumnNames, converter);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
yieldRowsJs() {
|
|
217
|
+
return this.yieldConvertedRows(JSDuckDBValueConverter_1.JSDuckDBValueConverter);
|
|
218
|
+
}
|
|
219
|
+
yieldRowsJson() {
|
|
220
|
+
return this.yieldConvertedRows(JsonDuckDBValueConverter_1.JsonDuckDBValueConverter);
|
|
221
|
+
}
|
|
222
|
+
yieldRowObjectJs() {
|
|
223
|
+
return this.yieldConvertedRowObjects(JSDuckDBValueConverter_1.JSDuckDBValueConverter);
|
|
224
|
+
}
|
|
225
|
+
yieldRowObjectJson() {
|
|
226
|
+
return this.yieldConvertedRowObjects(JsonDuckDBValueConverter_1.JsonDuckDBValueConverter);
|
|
227
|
+
}
|
|
183
228
|
}
|
|
184
229
|
exports.DuckDBResult = DuckDBResult;
|
package/lib/DuckDBType.d.ts
CHANGED
|
@@ -336,20 +336,20 @@ export declare class DuckDBAnyType extends BaseDuckDBType<DuckDBTypeId.ANY> {
|
|
|
336
336
|
static create(alias?: string): DuckDBAnyType;
|
|
337
337
|
}
|
|
338
338
|
export declare const ANY: DuckDBAnyType;
|
|
339
|
-
export declare class
|
|
339
|
+
export declare class DuckDBBigNumType extends BaseDuckDBType<DuckDBTypeId.BIGNUM> {
|
|
340
340
|
constructor(alias?: string);
|
|
341
|
-
static readonly instance:
|
|
342
|
-
static create(alias?: string):
|
|
341
|
+
static readonly instance: DuckDBBigNumType;
|
|
342
|
+
static create(alias?: string): DuckDBBigNumType;
|
|
343
343
|
static readonly Max: bigint;
|
|
344
344
|
static readonly Min: bigint;
|
|
345
345
|
get max(): bigint;
|
|
346
346
|
get min(): bigint;
|
|
347
347
|
}
|
|
348
|
-
export declare const
|
|
348
|
+
export declare const BIGNUM: DuckDBBigNumType;
|
|
349
349
|
export declare class DuckDBSQLNullType extends BaseDuckDBType<DuckDBTypeId.SQLNULL> {
|
|
350
350
|
constructor(alias?: string);
|
|
351
351
|
static readonly instance: DuckDBSQLNullType;
|
|
352
352
|
static create(alias?: string): DuckDBSQLNullType;
|
|
353
353
|
}
|
|
354
354
|
export declare const SQLNULL: DuckDBSQLNullType;
|
|
355
|
-
export type DuckDBType = DuckDBBooleanType | DuckDBTinyIntType | DuckDBSmallIntType | DuckDBIntegerType | DuckDBBigIntType | DuckDBUTinyIntType | DuckDBUSmallIntType | DuckDBUIntegerType | DuckDBUBigIntType | DuckDBFloatType | DuckDBDoubleType | DuckDBTimestampType | DuckDBDateType | DuckDBTimeType | DuckDBIntervalType | DuckDBHugeIntType | DuckDBUHugeIntType | DuckDBVarCharType | DuckDBBlobType | DuckDBDecimalType | DuckDBTimestampSecondsType | DuckDBTimestampMillisecondsType | DuckDBTimestampNanosecondsType | DuckDBEnumType | DuckDBListType | DuckDBStructType | DuckDBMapType | DuckDBArrayType | DuckDBUUIDType | DuckDBUnionType | DuckDBBitType | DuckDBTimeTZType | DuckDBTimestampTZType | DuckDBAnyType |
|
|
355
|
+
export type DuckDBType = DuckDBBooleanType | DuckDBTinyIntType | DuckDBSmallIntType | DuckDBIntegerType | DuckDBBigIntType | DuckDBUTinyIntType | DuckDBUSmallIntType | DuckDBUIntegerType | DuckDBUBigIntType | DuckDBFloatType | DuckDBDoubleType | DuckDBTimestampType | DuckDBDateType | DuckDBTimeType | DuckDBIntervalType | DuckDBHugeIntType | DuckDBUHugeIntType | DuckDBVarCharType | DuckDBBlobType | DuckDBDecimalType | DuckDBTimestampSecondsType | DuckDBTimestampMillisecondsType | DuckDBTimestampNanosecondsType | DuckDBEnumType | DuckDBListType | DuckDBStructType | DuckDBMapType | DuckDBArrayType | DuckDBUUIDType | DuckDBUnionType | DuckDBBitType | DuckDBTimeTZType | DuckDBTimestampTZType | DuckDBAnyType | DuckDBBigNumType | DuckDBSQLNullType;
|
package/lib/DuckDBType.js
CHANGED
|
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.DuckDBStructType = exports.DuckDBListType = exports.DuckDBEnumType = exports.TIMESTAMP_NS = exports.DuckDBTimestampNanosecondsType = exports.TIMESTAMP_MS = exports.DuckDBTimestampMillisecondsType = exports.TIMESTAMP_S = exports.DuckDBTimestampSecondsType = exports.DuckDBDecimalType = exports.BLOB = exports.DuckDBBlobType = exports.VARCHAR = exports.DuckDBVarCharType = exports.UHUGEINT = exports.DuckDBUHugeIntType = exports.HUGEINT = exports.DuckDBHugeIntType = exports.INTERVAL = exports.DuckDBIntervalType = exports.TIME = exports.DuckDBTimeType = exports.DATE = exports.DuckDBDateType = exports.DuckDBTimestampMicrosecondsType = exports.TIMESTAMP = exports.DuckDBTimestampType = exports.DOUBLE = exports.DuckDBDoubleType = exports.FLOAT = exports.DuckDBFloatType = exports.UBIGINT = exports.DuckDBUBigIntType = exports.UINTEGER = exports.DuckDBUIntegerType = exports.USMALLINT = exports.DuckDBUSmallIntType = exports.UTINYINT = exports.DuckDBUTinyIntType = exports.BIGINT = exports.DuckDBBigIntType = exports.INTEGER = exports.DuckDBIntegerType = exports.SMALLINT = exports.DuckDBSmallIntType = exports.TINYINT = exports.DuckDBTinyIntType = exports.BOOLEAN = exports.DuckDBBooleanType = exports.BaseDuckDBType = void 0;
|
|
7
|
-
exports.SQLNULL = exports.DuckDBSQLNullType = exports.
|
|
7
|
+
exports.SQLNULL = exports.DuckDBSQLNullType = exports.BIGNUM = exports.DuckDBBigNumType = exports.ANY = exports.DuckDBAnyType = exports.TIMESTAMPTZ = exports.DuckDBTimestampTZType = exports.TIMETZ = exports.DuckDBTimeTZType = exports.BIT = exports.DuckDBBitType = exports.DuckDBUnionType = exports.UUID = exports.DuckDBUUIDType = exports.DuckDBArrayType = exports.DuckDBMapType = void 0;
|
|
8
8
|
exports.DECIMAL = DECIMAL;
|
|
9
9
|
exports.ENUM8 = ENUM8;
|
|
10
10
|
exports.ENUM16 = ENUM16;
|
|
@@ -865,25 +865,25 @@ class DuckDBAnyType extends BaseDuckDBType {
|
|
|
865
865
|
}
|
|
866
866
|
exports.DuckDBAnyType = DuckDBAnyType;
|
|
867
867
|
exports.ANY = DuckDBAnyType.instance;
|
|
868
|
-
class
|
|
868
|
+
class DuckDBBigNumType extends BaseDuckDBType {
|
|
869
869
|
constructor(alias) {
|
|
870
|
-
super(DuckDBTypeId_1.DuckDBTypeId.
|
|
870
|
+
super(DuckDBTypeId_1.DuckDBTypeId.BIGNUM, alias);
|
|
871
871
|
}
|
|
872
|
-
static instance = new
|
|
872
|
+
static instance = new DuckDBBigNumType();
|
|
873
873
|
static create(alias) {
|
|
874
|
-
return alias ? new
|
|
874
|
+
return alias ? new DuckDBBigNumType(alias) : DuckDBBigNumType.instance;
|
|
875
875
|
}
|
|
876
876
|
static Max = 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368n;
|
|
877
877
|
static Min = -179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368n;
|
|
878
878
|
get max() {
|
|
879
|
-
return
|
|
879
|
+
return DuckDBBigNumType.Max;
|
|
880
880
|
}
|
|
881
881
|
get min() {
|
|
882
|
-
return
|
|
882
|
+
return DuckDBBigNumType.Min;
|
|
883
883
|
}
|
|
884
884
|
}
|
|
885
|
-
exports.
|
|
886
|
-
exports.
|
|
885
|
+
exports.DuckDBBigNumType = DuckDBBigNumType;
|
|
886
|
+
exports.BIGNUM = DuckDBBigNumType.instance;
|
|
887
887
|
class DuckDBSQLNullType extends BaseDuckDBType {
|
|
888
888
|
constructor(alias) {
|
|
889
889
|
super(DuckDBTypeId_1.DuckDBTypeId.SQLNULL, alias);
|
package/lib/DuckDBTypeId.d.ts
CHANGED
package/lib/DuckDBTypeId.js
CHANGED
|
@@ -39,6 +39,6 @@ var DuckDBTypeId;
|
|
|
39
39
|
DuckDBTypeId[DuckDBTypeId["TIME_TZ"] = 30] = "TIME_TZ";
|
|
40
40
|
DuckDBTypeId[DuckDBTypeId["TIMESTAMP_TZ"] = 31] = "TIMESTAMP_TZ";
|
|
41
41
|
DuckDBTypeId[DuckDBTypeId["ANY"] = 34] = "ANY";
|
|
42
|
-
DuckDBTypeId[DuckDBTypeId["
|
|
42
|
+
DuckDBTypeId[DuckDBTypeId["BIGNUM"] = 35] = "BIGNUM";
|
|
43
43
|
DuckDBTypeId[DuckDBTypeId["SQLNULL"] = 36] = "SQLNULL";
|
|
44
44
|
})(DuckDBTypeId || (exports.DuckDBTypeId = DuckDBTypeId = {}));
|
package/lib/DuckDBVector.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import duckdb from '@duckdb/node-bindings';
|
|
2
|
-
import { DuckDBArrayType, DuckDBBigIntType, DuckDBBitType, DuckDBBlobType, DuckDBBooleanType, DuckDBDateType, DuckDBDecimalType, DuckDBDoubleType, DuckDBEnumType, DuckDBFloatType, DuckDBHugeIntType, DuckDBIntegerType, DuckDBIntervalType, DuckDBListType, DuckDBMapType, DuckDBSmallIntType, DuckDBStructType, DuckDBTimeTZType, DuckDBTimeType, DuckDBTimestampMillisecondsType, DuckDBTimestampNanosecondsType, DuckDBTimestampSecondsType, DuckDBTimestampTZType, DuckDBTimestampType, DuckDBTinyIntType, DuckDBType, DuckDBUBigIntType, DuckDBUHugeIntType, DuckDBUIntegerType, DuckDBUSmallIntType, DuckDBUTinyIntType, DuckDBUUIDType, DuckDBUnionType, DuckDBVarCharType
|
|
2
|
+
import { DuckDBArrayType, DuckDBBigIntType, DuckDBBigNumType, DuckDBBitType, DuckDBBlobType, DuckDBBooleanType, DuckDBDateType, DuckDBDecimalType, DuckDBDoubleType, DuckDBEnumType, DuckDBFloatType, DuckDBHugeIntType, DuckDBIntegerType, DuckDBIntervalType, DuckDBListType, DuckDBMapType, DuckDBSmallIntType, DuckDBStructType, DuckDBTimeTZType, DuckDBTimeType, DuckDBTimestampMillisecondsType, DuckDBTimestampNanosecondsType, DuckDBTimestampSecondsType, DuckDBTimestampTZType, DuckDBTimestampType, DuckDBTinyIntType, DuckDBType, DuckDBUBigIntType, DuckDBUHugeIntType, DuckDBUIntegerType, DuckDBUSmallIntType, DuckDBUTinyIntType, DuckDBUUIDType, DuckDBUnionType, DuckDBVarCharType } from './DuckDBType';
|
|
3
3
|
import { DuckDBArrayValue, DuckDBBitValue, DuckDBBlobValue, DuckDBDateValue, DuckDBDecimalValue, DuckDBIntervalValue, DuckDBListValue, DuckDBMapValue, DuckDBStructValue, DuckDBTimeTZValue, DuckDBTimeValue, DuckDBTimestampMillisecondsValue, DuckDBTimestampNanosecondsValue, DuckDBTimestampSecondsValue, DuckDBTimestampTZValue, DuckDBTimestampValue, DuckDBUUIDValue, DuckDBUnionValue, DuckDBValue } from './values';
|
|
4
4
|
declare class DuckDBValidity {
|
|
5
5
|
private data;
|
|
@@ -563,7 +563,7 @@ export declare class DuckDBTimestampTZVector extends DuckDBVector<DuckDBTimestam
|
|
|
563
563
|
flush(): void;
|
|
564
564
|
slice(offset: number, length: number): DuckDBTimestampTZVector;
|
|
565
565
|
}
|
|
566
|
-
export declare class
|
|
566
|
+
export declare class DuckDBBigNumVector extends DuckDBVector<bigint> {
|
|
567
567
|
private readonly dataView;
|
|
568
568
|
private readonly validity;
|
|
569
569
|
private readonly vector;
|
|
@@ -572,12 +572,12 @@ export declare class DuckDBVarIntVector extends DuckDBVector<bigint> {
|
|
|
572
572
|
private readonly itemCache;
|
|
573
573
|
private readonly itemCacheDirty;
|
|
574
574
|
constructor(dataView: DataView, validity: DuckDBValidity, vector: duckdb.Vector, itemOffset: number, itemCount: number);
|
|
575
|
-
static fromRawVector(vector: duckdb.Vector, itemCount: number):
|
|
576
|
-
get type():
|
|
575
|
+
static fromRawVector(vector: duckdb.Vector, itemCount: number): DuckDBBigNumVector;
|
|
576
|
+
get type(): DuckDBBigNumType;
|
|
577
577
|
get itemCount(): number;
|
|
578
578
|
getItem(itemIndex: number): bigint | null;
|
|
579
579
|
setItem(itemIndex: number, value: bigint | null): void;
|
|
580
580
|
flush(): void;
|
|
581
|
-
slice(offset: number, length: number):
|
|
581
|
+
slice(offset: number, length: number): DuckDBBigNumVector;
|
|
582
582
|
}
|
|
583
583
|
export {};
|
package/lib/DuckDBVector.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.DuckDBBigNumVector = exports.DuckDBTimestampTZVector = exports.DuckDBTimeTZVector = exports.DuckDBBitVector = exports.DuckDBUnionVector = exports.DuckDBUUIDVector = exports.DuckDBArrayVector = exports.DuckDBMapVector = exports.DuckDBStructVector = exports.DuckDBListVector = exports.DuckDBEnum32Vector = exports.DuckDBEnum16Vector = exports.DuckDBEnum8Vector = exports.DuckDBTimestampNanosecondsVector = exports.DuckDBTimestampMillisecondsVector = exports.DuckDBTimestampSecondsVector = exports.DuckDBDecimal128Vector = exports.DuckDBDecimal64Vector = exports.DuckDBDecimal32Vector = exports.DuckDBDecimal16Vector = exports.DuckDBBlobVector = exports.DuckDBVarCharVector = exports.DuckDBUHugeIntVector = exports.DuckDBHugeIntVector = exports.DuckDBIntervalVector = exports.DuckDBTimeVector = exports.DuckDBDateVector = exports.DuckDBTimestampVector = exports.DuckDBDoubleVector = exports.DuckDBFloatVector = exports.DuckDBUBigIntVector = exports.DuckDBUIntegerVector = exports.DuckDBUSmallIntVector = exports.DuckDBUTinyIntVector = exports.DuckDBBigIntVector = exports.DuckDBIntegerVector = exports.DuckDBSmallIntVector = exports.DuckDBTinyIntVector = exports.DuckDBBooleanVector = exports.DuckDBVector = void 0;
|
|
7
7
|
const node_bindings_1 = __importDefault(require("@duckdb/node-bindings"));
|
|
8
8
|
const os_1 = __importDefault(require("os"));
|
|
9
9
|
const DuckDBLogicalType_1 = require("./DuckDBLogicalType");
|
|
@@ -69,7 +69,7 @@ function getBuffer(dataView, offset) {
|
|
|
69
69
|
const stringBytes = getStringBytes(dataView, offset);
|
|
70
70
|
return Buffer.from(stringBytes);
|
|
71
71
|
}
|
|
72
|
-
function
|
|
72
|
+
function getBigNumFromBytes(bytes) {
|
|
73
73
|
const firstByte = bytes[0];
|
|
74
74
|
const positive = (firstByte & 0x80) > 0;
|
|
75
75
|
const uint64Mask = positive ? 0n : 0xffffffffffffffffn;
|
|
@@ -89,32 +89,32 @@ function getVarIntFromBytes(bytes) {
|
|
|
89
89
|
}
|
|
90
90
|
return positive ? result : -result;
|
|
91
91
|
}
|
|
92
|
-
function
|
|
92
|
+
function getBytesFromBigNum(bignum) {
|
|
93
93
|
const numberBytes = []; // little endian
|
|
94
|
-
const negative =
|
|
95
|
-
if (
|
|
94
|
+
const negative = bignum < 0;
|
|
95
|
+
if (bignum === 0n) {
|
|
96
96
|
numberBytes.push(0);
|
|
97
97
|
}
|
|
98
98
|
else {
|
|
99
|
-
let vi =
|
|
99
|
+
let vi = bignum < 0 ? -bignum : bignum;
|
|
100
100
|
while (vi !== 0n) {
|
|
101
101
|
numberBytes.push(Number(BigInt.asUintN(8, vi)));
|
|
102
102
|
vi >>= 8n;
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
|
-
const
|
|
105
|
+
const bigNumBytes = new Uint8Array(3 + numberBytes.length); // big endian
|
|
106
106
|
let header = 0x800000 | numberBytes.length;
|
|
107
107
|
if (negative) {
|
|
108
108
|
header = ~header;
|
|
109
109
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
110
|
+
bigNumBytes[0] = 0xff & (header >> 16);
|
|
111
|
+
bigNumBytes[1] = 0xff & (header >> 8);
|
|
112
|
+
bigNumBytes[2] = 0xff & header;
|
|
113
113
|
for (let i = 0; i < numberBytes.length; i++) {
|
|
114
114
|
const byte = numberBytes[numberBytes.length - 1 - i];
|
|
115
|
-
|
|
115
|
+
bigNumBytes[3 + i] = negative ? ~byte : byte;
|
|
116
116
|
}
|
|
117
|
-
return
|
|
117
|
+
return bigNumBytes;
|
|
118
118
|
}
|
|
119
119
|
function getBoolean1(dataView, offset) {
|
|
120
120
|
return getUInt8(dataView, offset) !== 0;
|
|
@@ -434,8 +434,8 @@ class DuckDBVector {
|
|
|
434
434
|
return DuckDBTimestampTZVector.fromRawVector(vector, itemCount);
|
|
435
435
|
case DuckDBTypeId_1.DuckDBTypeId.ANY:
|
|
436
436
|
throw new Error(`Invalid vector type: ANY`);
|
|
437
|
-
case DuckDBTypeId_1.DuckDBTypeId.
|
|
438
|
-
return
|
|
437
|
+
case DuckDBTypeId_1.DuckDBTypeId.BIGNUM:
|
|
438
|
+
return DuckDBBigNumVector.fromRawVector(vector, itemCount);
|
|
439
439
|
case DuckDBTypeId_1.DuckDBTypeId.SQLNULL:
|
|
440
440
|
throw new Error(`Invalid vector type: SQLNULL`);
|
|
441
441
|
default:
|
|
@@ -2413,7 +2413,7 @@ class DuckDBTimestampTZVector extends DuckDBVector {
|
|
|
2413
2413
|
}
|
|
2414
2414
|
}
|
|
2415
2415
|
exports.DuckDBTimestampTZVector = DuckDBTimestampTZVector;
|
|
2416
|
-
class
|
|
2416
|
+
class DuckDBBigNumVector extends DuckDBVector {
|
|
2417
2417
|
dataView;
|
|
2418
2418
|
validity;
|
|
2419
2419
|
vector;
|
|
@@ -2435,10 +2435,10 @@ class DuckDBVarIntVector extends DuckDBVector {
|
|
|
2435
2435
|
const data = vectorData(vector, itemCount * 16);
|
|
2436
2436
|
const dataView = new DataView(data.buffer, data.byteOffset, data.byteLength);
|
|
2437
2437
|
const validity = DuckDBValidity.fromVector(vector, itemCount);
|
|
2438
|
-
return new
|
|
2438
|
+
return new DuckDBBigNumVector(dataView, validity, vector, 0, itemCount);
|
|
2439
2439
|
}
|
|
2440
2440
|
get type() {
|
|
2441
|
-
return DuckDBType_1.
|
|
2441
|
+
return DuckDBType_1.DuckDBBigNumType.instance;
|
|
2442
2442
|
}
|
|
2443
2443
|
get itemCount() {
|
|
2444
2444
|
return this._itemCount;
|
|
@@ -2448,7 +2448,7 @@ class DuckDBVarIntVector extends DuckDBVector {
|
|
|
2448
2448
|
return null;
|
|
2449
2449
|
}
|
|
2450
2450
|
const bytes = getStringBytes(this.dataView, itemIndex * 16);
|
|
2451
|
-
return bytes ?
|
|
2451
|
+
return bytes ? getBigNumFromBytes(bytes) : null;
|
|
2452
2452
|
}
|
|
2453
2453
|
setItem(itemIndex, value) {
|
|
2454
2454
|
this.itemCache[itemIndex] = value;
|
|
@@ -2460,7 +2460,7 @@ class DuckDBVarIntVector extends DuckDBVector {
|
|
|
2460
2460
|
if (this.itemCacheDirty[itemIndex]) {
|
|
2461
2461
|
const cachedItem = this.itemCache[itemIndex];
|
|
2462
2462
|
if (cachedItem !== undefined && cachedItem !== null) {
|
|
2463
|
-
node_bindings_1.default.vector_assign_string_element_len(this.vector, this.itemOffset + itemIndex,
|
|
2463
|
+
node_bindings_1.default.vector_assign_string_element_len(this.vector, this.itemOffset + itemIndex, getBytesFromBigNum(cachedItem));
|
|
2464
2464
|
}
|
|
2465
2465
|
this.itemCacheDirty[itemIndex] = false;
|
|
2466
2466
|
}
|
|
@@ -2468,7 +2468,7 @@ class DuckDBVarIntVector extends DuckDBVector {
|
|
|
2468
2468
|
this.validity.flush(this.vector);
|
|
2469
2469
|
}
|
|
2470
2470
|
slice(offset, length) {
|
|
2471
|
-
return new
|
|
2471
|
+
return new DuckDBBigNumVector(new DataView(this.dataView.buffer, this.dataView.byteOffset + offset * 16, length * 16), this.validity.slice(offset, length), this.vector, offset, length);
|
|
2472
2472
|
}
|
|
2473
2473
|
}
|
|
2474
|
-
exports.
|
|
2474
|
+
exports.DuckDBBigNumVector = DuckDBBigNumVector;
|
|
@@ -40,7 +40,7 @@ const JSConvertersByTypeId = {
|
|
|
40
40
|
[DuckDBTypeId_1.DuckDBTypeId.TIME_TZ]: DuckDBValueConverters_1.objectFromTimeTZValue,
|
|
41
41
|
[DuckDBTypeId_1.DuckDBTypeId.TIMESTAMP_TZ]: DuckDBValueConverters_1.dateFromTimestampTZValue,
|
|
42
42
|
[DuckDBTypeId_1.DuckDBTypeId.ANY]: DuckDBValueConverters_1.unsupportedConverter,
|
|
43
|
-
[DuckDBTypeId_1.DuckDBTypeId.
|
|
43
|
+
[DuckDBTypeId_1.DuckDBTypeId.BIGNUM]: DuckDBValueConverters_1.bigintFromBigIntValue,
|
|
44
44
|
[DuckDBTypeId_1.DuckDBTypeId.SQLNULL]: DuckDBValueConverters_1.nullConverter,
|
|
45
45
|
};
|
|
46
46
|
exports.JSDuckDBValueConverter = (0, createDuckDBValueConverter_1.createDuckDBValueConverter)(JSConvertersByTypeId);
|
|
@@ -40,7 +40,7 @@ const JsonConvertersByTypeId = {
|
|
|
40
40
|
[DuckDBTypeId_1.DuckDBTypeId.TIME_TZ]: DuckDBValueConverters_1.stringFromValue,
|
|
41
41
|
[DuckDBTypeId_1.DuckDBTypeId.TIMESTAMP_TZ]: DuckDBValueConverters_1.stringFromValue,
|
|
42
42
|
[DuckDBTypeId_1.DuckDBTypeId.ANY]: DuckDBValueConverters_1.unsupportedConverter,
|
|
43
|
-
[DuckDBTypeId_1.DuckDBTypeId.
|
|
43
|
+
[DuckDBTypeId_1.DuckDBTypeId.BIGNUM]: DuckDBValueConverters_1.stringFromValue,
|
|
44
44
|
[DuckDBTypeId_1.DuckDBTypeId.SQLNULL]: DuckDBValueConverters_1.nullConverter,
|
|
45
45
|
};
|
|
46
46
|
exports.JsonDuckDBValueConverter = (0, createDuckDBValueConverter_1.createDuckDBValueConverter)(JsonConvertersByTypeId);
|
package/lib/createValue.js
CHANGED
|
@@ -200,9 +200,9 @@ function createValue(type, input) {
|
|
|
200
200
|
throw new Error(`input is not a DuckDBTimestampTZValue`);
|
|
201
201
|
case DuckDBTypeId_1.DuckDBTypeId.ANY:
|
|
202
202
|
throw new Error(`Cannot create values of type ANY. Specify a specific type.`);
|
|
203
|
-
case DuckDBTypeId_1.DuckDBTypeId.
|
|
203
|
+
case DuckDBTypeId_1.DuckDBTypeId.BIGNUM:
|
|
204
204
|
if (typeof input === 'bigint') {
|
|
205
|
-
return node_bindings_1.default.
|
|
205
|
+
return node_bindings_1.default.create_bignum(input);
|
|
206
206
|
}
|
|
207
207
|
throw new Error(`input is not a bigint`);
|
|
208
208
|
case DuckDBTypeId_1.DuckDBTypeId.SQLNULL:
|
package/lib/sql.js
CHANGED
|
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.quotedString = quotedString;
|
|
4
4
|
exports.quotedIdentifier = quotedIdentifier;
|
|
5
5
|
function quotedString(input) {
|
|
6
|
-
return `'${input.
|
|
6
|
+
return `'${input.replaceAll(`'`, `''`)}'`;
|
|
7
7
|
}
|
|
8
8
|
function quotedIdentifier(input) {
|
|
9
|
-
return `"${input.
|
|
9
|
+
return `"${input.replaceAll(`"`, `""`)}"`;
|
|
10
10
|
}
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@duckdb/node-api",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0-r.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"types": "./lib/index.d.ts",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@duckdb/node-bindings": "1.
|
|
8
|
+
"@duckdb/node-bindings": "1.4.0-r.2"
|
|
9
9
|
},
|
|
10
10
|
"repository": {
|
|
11
11
|
"type": "git",
|