Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dem.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
{
"protocol": "https",
"path": "deno.land/x/sqlite",
"version": "v2.1.0",
"version": "v2.2.1",
"files": [
"/mod.ts"
]
Expand Down
16 changes: 16 additions & 0 deletions src/driver/sqlite-abstract/AbstractSqliteDriver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,12 @@ export abstract class AbstractSqliteDriver implements Driver {
} else if (columnMetadata.type === "simple-enum") {
return DateUtils.simpleEnumToString(value);
}
// Some types are treated differently from the original typeorm.
else if (typeof value === "bigint") {
// Unlike node-sqlite, deno-sqlite uses BigInt for large numbers.
// https://github.com/dyedgreen/deno-sqlite/pull/67
return value.toString();
}

return value;
}
Expand Down Expand Up @@ -320,6 +326,16 @@ export abstract class AbstractSqliteDriver implements Driver {
value = DateUtils.stringToSimpleEnum(value, columnMetadata);

}
// Some types are treated differently from the original typeorm.
else if (
columnMetadata.type === "int8" ||
columnMetadata.type === "bigint" ||
columnMetadata.type === "unsigned big int" ||
columnMetadata.type === BigInt) {
// Unlike node-sqlite, deno-sqlite uses BigInt for large numbers.
// https://github.com/dyedgreen/deno-sqlite/pull/67
value = BigInt(value);
}

if (columnMetadata.transformer)
value = ApplyValueTransformers.transformFrom(columnMetadata.transformer, value);
Expand Down
3 changes: 2 additions & 1 deletion src/driver/types/ColumnTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,4 +207,5 @@ export type ColumnType = WithPrecisionColumnType
|DateConstructor
|NumberConstructor
|StringConstructor
|Uint8ArrayConstructor; // TODO(uki001) This type is not fully tested yet.
|Uint8ArrayConstructor
|BigIntConstructor;
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,19 @@ describe("database schema > column types > sqlite", () => {
post.integer = 2147483647;
post.int = 2147483647;
post.int2 = 32767;
post.int8 = 8223372036854775807;
post.int8 = 8223372036854775807n; // Unlike node-sqlite, deno-sqlite uses BigInt for large numbers.
post.tinyint = 127;
post.smallint = 32767;
post.mediumint = 8388607;
post.bigint = 8223372036854775807;
post.unsignedBigInt = 8223372036854775807;
post.bigint = 8223372036854775807n; // Unlike node-sqlite, deno-sqlite uses BigInt for large numbers.
post.unsignedBigInt = 8223372036854775807n; // Unlike node-sqlite, deno-sqlite uses BigInt for large numbers.
post.character = "A";
post.varchar = "This is varchar";
post.varyingCharacter = "This is varying character";
post.nchar = "This is nchar";
post.nativeCharacter = "This is native character";
post.nvarchar = "This is nvarchar";
// TODO(uki00a) not fully tested yet.
post.blob = encoder.encode("This is blob");/* new Buffer("This is blob"); */
post.blob = encoder.encode("This is blob");
post.clob = "This is clob";
post.text = "This is text";
post.real = 10.5;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export class Post {
int2!: number;

@Column("int8")
int8!: number;
int8!: BigInt;

@Column("tinyint")
tinyint!: number;
Expand All @@ -38,10 +38,10 @@ export class Post {
mediumint!: number;

@Column("bigint")
bigint!: number;
bigint!: BigInt;

@Column("unsigned big int")
unsignedBigInt!: number;
unsignedBigInt!: BigInt;

// -------------------------------------------------------------------------
// Character Types
Expand Down
2 changes: 1 addition & 1 deletion vendor/https/deno.land/x/sqlite/mod.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from "https://deno.land/x/sqlite@v2.1.0/mod.ts";
export * from "https://deno.land/x/sqlite@v2.2.1/mod.ts";