Skip to content

Commit 096d6cb

Browse files
Soremwarpetuhovskiy
andcommitted
chore: Update for Deno 1.26.2 (denodrivers#413)
Co-authored-by: Arthur Petukhovsky <[email protected]>
1 parent 8a07131 commit 096d6cb

File tree

15 files changed

+161
-138
lines changed

15 files changed

+161
-138
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
- name: Setup Deno
1313
uses: denoland/setup-deno@v1
1414
with:
15-
deno-version: 1.17.3
15+
deno-version: 1.26.2
1616

1717
- name: Format
1818
run: deno fmt --check
@@ -45,7 +45,7 @@ jobs:
4545
- name: Report no typechecking tests status
4646
id: no_typecheck_status
4747
if: steps.no_typecheck.outcome == 'success'
48-
run: echo "::set-output name=status::success"
48+
run: echo "name=status::success" >> $GITHUB_OUTPUT
4949
outputs:
5050
no_typecheck: ${{ steps.no_typecheck.outputs.stdout }}
5151
no_typecheck_status: ${{ steps.no_typecheck_status.outputs.status }}

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM denoland/deno:alpine-1.17.3
1+
FROM denoland/deno:alpine-1.26.2
22
WORKDIR /app
33

44
# Install wait utility

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ await client.connect();
3232
}
3333

3434
{
35-
const result = await client.queryArray
36-
`SELECT ID, NAME FROM PEOPLE WHERE ID = ${1}`;
35+
const result = await client
36+
.queryArray`SELECT ID, NAME FROM PEOPLE WHERE ID = ${1}`;
3737
console.log(result.rows); // [[1, 'Carlos']]
3838
}
3939

@@ -43,8 +43,8 @@ await client.connect();
4343
}
4444

4545
{
46-
const result = await client.queryObject
47-
`SELECT ID, NAME FROM PEOPLE WHERE ID = ${1}`;
46+
const result = await client
47+
.queryObject`SELECT ID, NAME FROM PEOPLE WHERE ID = ${1}`;
4848
console.log(result.rows); // [{id: 1, name: 'Carlos'}]
4949
}
5050

connection/connection_params.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ export function createParams(
360360
if (parsed_host.protocol === "file:") {
361361
host = fromFileUrl(parsed_host);
362362
} else {
363-
throw new ConnectionParamsError(
363+
throw new Error(
364364
"The provided host is not a file path",
365365
);
366366
}

connection/scram.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ async function deriveKeySignatures(
110110
salt,
111111
},
112112
pbkdf2_password,
113-
{ name: "HMAC", hash: "SHA-256" },
113+
{ name: "HMAC", hash: "SHA-256", length: 256 },
114114
false,
115115
["sign"],
116116
);

deps.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
export * as base64 from "https://deno.land/std@0.141.0/encoding/base64.ts";
2-
export * as hex from "https://deno.land/std@0.141.0/encoding/hex.ts";
3-
export * as date from "https://deno.land/std@0.141.0/datetime/mod.ts";
1+
export * as base64 from "https://deno.land/std@0.160.0/encoding/base64.ts";
2+
export * as hex from "https://deno.land/std@0.160.0/encoding/hex.ts";
3+
export * as date from "https://deno.land/std@0.160.0/datetime/mod.ts";
44
export {
55
BufReader,
66
BufWriter,
7-
} from "https://deno.land/std@0.141.0/io/buffer.ts";
8-
export { copy } from "https://deno.land/std@0.141.0/bytes/mod.ts";
9-
export { crypto } from "https://deno.land/std@0.141.0/crypto/mod.ts";
7+
} from "https://deno.land/std@0.160.0/io/buffer.ts";
8+
export { copy } from "https://deno.land/std@0.160.0/bytes/mod.ts";
9+
export { crypto } from "https://deno.land/std@0.160.0/crypto/mod.ts";
1010
export {
1111
type Deferred,
1212
deferred,
1313
delay,
14-
} from "https://deno.land/std@0.141.0/async/mod.ts";
15-
export { bold, yellow } from "https://deno.land/std@0.141.0/fmt/colors.ts";
14+
} from "https://deno.land/std@0.160.0/async/mod.ts";
15+
export { bold, yellow } from "https://deno.land/std@0.160.0/fmt/colors.ts";
1616
export {
1717
fromFileUrl,
1818
isAbsolute,
1919
join as joinPath,
20-
} from "https://deno.land/std@0.141.0/path/mod.ts";
20+
} from "https://deno.land/std@0.160.0/path/mod.ts";

docker-compose.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ services:
6363
build: .
6464
# Name the image to be reused in no_check_tests
6565
image: postgres/tests
66-
command: sh -c "/wait && deno test --unstable -A --jobs"
66+
command: sh -c "/wait && deno test --unstable -A --parallel --check"
6767
depends_on:
6868
- postgres_clear
6969
- postgres_md5
@@ -74,7 +74,7 @@ services:
7474

7575
no_check_tests:
7676
image: postgres/tests
77-
command: sh -c "/wait && deno test --unstable -A --jobs --no-check"
77+
command: sh -c "/wait && deno test --unstable -A --parallel --no-check"
7878
depends_on:
7979
- tests
8080
environment:

docs/README.md

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -628,16 +628,16 @@ prepared statements with a nice and clear syntax for your queries
628628

629629
```ts
630630
{
631-
const result = await client.queryArray
632-
`SELECT ID, NAME FROM PEOPLE WHERE AGE > ${10} AND AGE < ${20}`;
631+
const result = await client
632+
.queryArray`SELECT ID, NAME FROM PEOPLE WHERE AGE > ${10} AND AGE < ${20}`;
633633
console.log(result.rows);
634634
}
635635

636636
{
637637
const min = 10;
638638
const max = 20;
639-
const result = await client.queryObject
640-
`SELECT ID, NAME FROM PEOPLE WHERE AGE > ${min} AND AGE < ${max}`;
639+
const result = await client
640+
.queryObject`SELECT ID, NAME FROM PEOPLE WHERE AGE > ${min} AND AGE < ${max}`;
641641
console.log(result.rows);
642642
}
643643
```
@@ -686,8 +686,8 @@ await client.queryArray`UPDATE TABLE X SET Y = 0 WHERE Z = ${my_id}`;
686686
// Invalid attempt to replace an specifier
687687
const my_table = "IMPORTANT_TABLE";
688688
const my_other_id = 41;
689-
await client.queryArray
690-
`DELETE FROM ${my_table} WHERE MY_COLUMN = ${my_other_id};`;
689+
await client
690+
.queryArray`DELETE FROM ${my_table} WHERE MY_COLUMN = ${my_other_id};`;
691691
```
692692

693693
### Specifying result type
@@ -706,8 +706,9 @@ intellisense
706706
}
707707

708708
{
709-
const array_result = await client.queryArray<[number, string]>
710-
`SELECT ID, NAME FROM PEOPLE WHERE ID = ${17}`;
709+
const array_result = await client.queryArray<
710+
[number, string]
711+
>`SELECT ID, NAME FROM PEOPLE WHERE ID = ${17}`;
711712
// [number, string]
712713
const person = array_result.rows[0];
713714
}
@@ -721,8 +722,9 @@ intellisense
721722
}
722723

723724
{
724-
const object_result = await client.queryObject<{ id: number; name: string }>
725-
`SELECT ID, NAME FROM PEOPLE WHERE ID = ${17}`;
725+
const object_result = await client.queryObject<
726+
{ id: number; name: string }
727+
>`SELECT ID, NAME FROM PEOPLE WHERE ID = ${17}`;
726728
// {id: number, name: string}
727729
const person = object_result.rows[0];
728730
}
@@ -1037,8 +1039,8 @@ const transaction = client_1.createTransaction("transaction_1");
10371039

10381040
await transaction.begin();
10391041

1040-
await transaction.queryArray
1041-
`CREATE TABLE TEST_RESULTS (USER_ID INTEGER, GRADE NUMERIC(10,2))`;
1042+
await transaction
1043+
.queryArray`CREATE TABLE TEST_RESULTS (USER_ID INTEGER, GRADE NUMERIC(10,2))`;
10421044
await transaction.queryArray`CREATE TABLE GRADUATED_STUDENTS (USER_ID INTEGER)`;
10431045

10441046
// This operation takes several minutes
@@ -1087,16 +1089,18 @@ following levels of transaction isolation:
10871089
await transaction.begin();
10881090
// This locks the current value of IMPORTANT_TABLE
10891091
// Up to this point, all other external changes will be included
1090-
const { rows: query_1 } = await transaction.queryObject<{ password: string }>
1091-
`SELECT PASSWORD FROM IMPORTANT_TABLE WHERE ID = ${my_id}`;
1092+
const { rows: query_1 } = await transaction.queryObject<
1093+
{ password: string }
1094+
>`SELECT PASSWORD FROM IMPORTANT_TABLE WHERE ID = ${my_id}`;
10921095
const password_1 = rows[0].password;
10931096

10941097
// Concurrent operation executed by a different user in a different part of the code
1095-
await client_2.queryArray
1096-
`UPDATE IMPORTANT_TABLE SET PASSWORD = 'something_else' WHERE ID = ${the_same_id}`;
1098+
await client_2
1099+
.queryArray`UPDATE IMPORTANT_TABLE SET PASSWORD = 'something_else' WHERE ID = ${the_same_id}`;
10971100

1098-
const { rows: query_2 } = await transaction.queryObject<{ password: string }>
1099-
`SELECT PASSWORD FROM IMPORTANT_TABLE WHERE ID = ${my_id}`;
1101+
const { rows: query_2 } = await transaction.queryObject<
1102+
{ password: string }
1103+
>`SELECT PASSWORD FROM IMPORTANT_TABLE WHERE ID = ${my_id}`;
11001104
const password_2 = rows[0].password;
11011105

11021106
// Database state is not updated while the transaction is ongoing
@@ -1124,18 +1128,19 @@ following levels of transaction isolation:
11241128
await transaction.begin();
11251129
// This locks the current value of IMPORTANT_TABLE
11261130
// Up to this point, all other external changes will be included
1127-
await transaction.queryObject<{ password: string }>
1128-
`SELECT PASSWORD FROM IMPORTANT_TABLE WHERE ID = ${my_id}`;
1131+
await transaction.queryObject<
1132+
{ password: string }
1133+
>`SELECT PASSWORD FROM IMPORTANT_TABLE WHERE ID = ${my_id}`;
11291134

11301135
// Concurrent operation executed by a different user in a different part of the code
1131-
await client_2.queryArray
1132-
`UPDATE IMPORTANT_TABLE SET PASSWORD = 'something_else' WHERE ID = ${the_same_id}`;
1136+
await client_2
1137+
.queryArray`UPDATE IMPORTANT_TABLE SET PASSWORD = 'something_else' WHERE ID = ${the_same_id}`;
11331138

11341139
// This statement will throw
11351140
// Target was modified outside of the transaction
11361141
// User may not be aware of the changes
1137-
await transaction.queryArray
1138-
`UPDATE IMPORTANT_TABLE SET PASSWORD = 'shiny_new_password' WHERE ID = ${the_same_id}`;
1142+
await transaction
1143+
.queryArray`UPDATE IMPORTANT_TABLE SET PASSWORD = 'shiny_new_password' WHERE ID = ${the_same_id}`;
11391144

11401145
// Transaction is aborted, no need to end it
11411146

query/query.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,14 @@ export type QueryArguments = unknown[] | Record<string, unknown>;
2828

2929
const commandTagRegexp = /^([A-Za-z]+)(?: (\d+))?(?: (\d+))?/;
3030

31-
type CommandType = (
31+
type CommandType =
3232
| "INSERT"
3333
| "DELETE"
3434
| "UPDATE"
3535
| "SELECT"
3636
| "MOVE"
3737
| "FETCH"
38-
| "COPY"
39-
);
38+
| "COPY";
4039

4140
export enum ResultType {
4241
ARRAY,

query/transaction.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -336,8 +336,9 @@ export class Transaction {
336336
async getSnapshot(): Promise<string> {
337337
this.#assertTransactionOpen();
338338

339-
const { rows } = await this.queryObject<{ snapshot: string }>
340-
`SELECT PG_EXPORT_SNAPSHOT() AS SNAPSHOT;`;
339+
const { rows } = await this.queryObject<
340+
{ snapshot: string }
341+
>`SELECT PG_EXPORT_SNAPSHOT() AS SNAPSHOT;`;
341342
return rows[0].snapshot;
342343
}
343344

0 commit comments

Comments
 (0)