Skip to content

Commit cd1c6b0

Browse files
committed
Fix build and test with latest Kysely
1 parent aee54e2 commit cd1c6b0

File tree

7 files changed

+840
-684
lines changed

7 files changed

+840
-684
lines changed

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,20 @@
1818
"build:cjs": "tsc -p tsconfig-cjs.json"
1919
},
2020
"devDependencies": {
21-
"@aws-sdk/client-rds-data": "^3.218.0",
21+
"@aws-sdk/client-rds-data": "^3.549.0",
2222
"@changesets/changelog-github": "^0.4.5",
2323
"@changesets/cli": "^2.23.2",
2424
"@tsconfig/node14": "^1.0.1",
2525
"@types/node": "^18.14.2",
26-
"kysely": "^0.26.0",
26+
"kysely": "^0.27.3",
2727
"perf_hooks": "^0.0.1",
2828
"prettier": "^2.8.4",
29+
"typescript": "^5.4.4",
2930
"vitest": "^0.18.1"
3031
},
3132
"peerDependencies": {
3233
"@aws-sdk/client-rds-data": "3.x",
33-
"kysely": "^0.26.0"
34+
"kysely": "^0.27.3"
3435
},
3536
"files": [
3637
"dist"

src/data-api-query-compiler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ function serialize(value: unknown): Pick<SqlParameter, "typeHint" | "value"> {
5858
&& typeof ((value as RSU).value as RSU).stringValue === "string"
5959
)
6060
((value as RSU).value as RSU).stringValue = fixStringValue(
61-
(value as RSS).typeHint,
61+
(value as RSS).typeHint as SqlParameter["typeHint"],
6262
((value as RSU).value as RSS).stringValue,
6363
);
6464
return value;

src/postgres-introspector.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ interface RawSchemaMetadata {
137137
interface RawColumnMetadata {
138138
column: string;
139139
table: string;
140-
is_view: string;
140+
is_view: boolean;
141141
schema: string;
142142
not_null: boolean;
143143
has_default: boolean;

test/harness.ts

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import { RDSData } from "@aws-sdk/client-rds-data";
2-
import { ColumnType, Generated, Kysely } from "kysely";
2+
import { ColumnType, Generated, Kysely, Migrator, FileMigrationProvider } from "kysely";
33
import { DataApiDialect } from "../src";
44
import { DataApiDriverConfig } from "../src/data-api-driver";
55
import path from "path";
6+
import { promises as fs } from "fs";
67

78
const TEST_DATABASE = "scratch";
89

@@ -71,7 +72,29 @@ export async function migrate() {
7172
resourceArn: opts.resourceArn,
7273
});
7374

74-
await db.migration.migrateToLatest(path.resolve("./test/migrations"));
75+
const migrator = new Migrator({
76+
db,
77+
provider: new FileMigrationProvider({
78+
fs,
79+
path,
80+
migrationFolder: path.join(__dirname, "migrations"),
81+
}),
82+
})
83+
84+
const { error, results } = await migrator.migrateToLatest();
85+
86+
results?.forEach((it) => {
87+
if (it.status === "Success") {
88+
console.log(`migration "${it.migrationName}" was executed successfully`);
89+
} else if (it.status === "Error") {
90+
console.error(`failed to execute migration "${it.migrationName}"`);
91+
}
92+
})
93+
94+
if (error) {
95+
console.error("failed to migrate");
96+
console.error(error);
97+
}
7598
}
7699

77100
export async function reset() {

test/migrations/test-migration1.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
async function up(db) {
22
await db.schema
33
.createTable("person")
4-
.addColumn("id", "integer", (col) => col.increments().primaryKey())
4+
.addColumn("id", "serial", (col) => col.primaryKey())
55
.addColumn("first_name", "varchar")
66
.addColumn("last_name", "varchar")
77
.addColumn("gender", "varchar(50)")
88
.execute();
99

1010
await db.schema
1111
.createTable("pet")
12-
.addColumn("id", "integer", (col) => col.increments().primaryKey())
12+
.addColumn("id", "serial", (col) => col.primaryKey())
1313
.addColumn("name", "varchar", (col) => col.notNull().unique())
1414
.addColumn("owner_id", "integer", (col) => col.references("person.id").onDelete("cascade"))
1515
.addColumn("species", "varchar")

test/temporary.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ it("insert and read", async () => {
3232
});
3333

3434
it("alias return", async () => {
35+
await db
36+
.insertInto("person")
37+
.values(PERSON)
38+
.execute();
39+
3540
const result = await db
3641
.selectFrom("person")
3742
.select(["first_name as first", "last_name as last"])

0 commit comments

Comments
 (0)