Skip to content

Commit 309c55c

Browse files
authored
Merge pull request #187 from Soremwar/1.6.0
Upgrade to Deno 1.6.0
2 parents c71cc2c + 6cf686e commit 309c55c

File tree

14 files changed

+64
-42
lines changed

14 files changed

+64
-42
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
- name: Install deno
2828
uses: denolib/setup-deno@master
2929
with:
30-
deno-version: 1.4.0
30+
deno-version: 1.6.0
3131

3232
- name: Check formatting
3333
run: deno fmt --check

array_parser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class ArrayParser {
7979
consumeDimensions(): void {
8080
if (this.source[0] === "[") {
8181
while (!this.isEof()) {
82-
let char = this.nextCharacter();
82+
const char = this.nextCharacter();
8383
if (char.value === "=") break;
8484
}
8585
}

decode.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,16 +139,16 @@ function decodeBytea(byteaStr: string): Uint8Array {
139139
}
140140

141141
function decodeByteaHex(byteaStr: string): Uint8Array {
142-
let bytesStr = byteaStr.slice(2);
143-
let bytes = new Uint8Array(bytesStr.length / 2);
142+
const bytesStr = byteaStr.slice(2);
143+
const bytes = new Uint8Array(bytesStr.length / 2);
144144
for (let i = 0, j = 0; i < bytesStr.length; i += 2, j++) {
145145
bytes[j] = parseInt(bytesStr[i] + bytesStr[i + 1], HEX);
146146
}
147147
return bytes;
148148
}
149149

150150
function decodeByteaEscape(byteaStr: string): Uint8Array {
151-
let bytes = [];
151+
const bytes = [];
152152
let i = 0;
153153
let k = 0;
154154
while (i < byteaStr.length) {

deps.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
export { BufReader, BufWriter } from "https://deno.land/std@0.69.0/io/bufio.ts";
2-
export { copyBytes } from "https://deno.land/std@0.67.0/bytes/mod.ts";
3-
export { deferred } from "https://deno.land/std@0.69.0/async/deferred.ts";
4-
export type { Deferred } from "https://deno.land/std@0.69.0/async/deferred.ts";
5-
export { createHash } from "https://deno.land/std@0.67.0/hash/mod.ts";
1+
export { BufReader, BufWriter } from "https://deno.land/std@0.80.0/io/bufio.ts";
2+
export { copy } from "https://deno.land/std@0.80.0/bytes/mod.ts";
3+
export { deferred } from "https://deno.land/std@0.80.0/async/deferred.ts";
4+
export type { Deferred } from "https://deno.land/std@0.80.0/async/deferred.ts";
5+
export { createHash } from "https://deno.land/std@0.80.0/hash/mod.ts";

encode.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ function encodeDate(date: Date): string {
4141

4242
function escapeArrayElement(value: unknown): string {
4343
// deno-lint-ignore no-explicit-any
44-
let strValue = (value as any).toString();
44+
const strValue = (value as any).toString();
4545
const escapedValue = strValue.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
4646

4747
return `"${escapedValue}"`;
@@ -73,7 +73,7 @@ function encodeArray(array: Array<unknown>): string {
7373
}
7474

7575
function encodeBytes(value: Uint8Array): string {
76-
let hex = Array.from(value)
76+
const hex = Array.from(value)
7777
.map((val) => (val < 10 ? `0${val.toString(16)}` : val.toString(16)))
7878
.join("");
7979
return `\\x${hex}`;

oid.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,25 @@ export const Oid = {
1414
xid: 28,
1515
cid: 29,
1616
oidvector: 30,
17+
// deno-lint-ignore camelcase
1718
pg_ddl_command: 32,
19+
// deno-lint-ignore camelcase
1820
pg_type: 71,
21+
// deno-lint-ignore camelcase
1922
pg_attribute: 75,
23+
// deno-lint-ignore camelcase
2024
pg_proc: 81,
25+
// deno-lint-ignore camelcase
2126
pg_class: 83,
2227
json: 114,
2328
xml: 142,
2429
_xml: 143,
30+
// deno-lint-ignore camelcase
2531
pg_node_tree: 194,
32+
// deno-lint-ignore camelcase
2633
json_array: 199,
2734
smgr: 210,
35+
// deno-lint-ignore camelcase
2836
index_am_handler: 325,
2937
point: 600,
3038
lseg: 601,
@@ -91,6 +99,7 @@ export const Oid = {
9199
interval: 1186,
92100
_interval: 1187,
93101
_numeric: 1231,
102+
// deno-lint-ignore camelcase
94103
pg_database: 1248,
95104
_cstring: 1263,
96105
timetz: 1266,
@@ -118,21 +127,30 @@ export const Oid = {
118127
anyarray: 2277,
119128
void: 2278,
120129
trigger: 2279,
130+
// deno-lint-ignore camelcase
121131
language_handler: 2280,
122132
internal: 2281,
123133
opaque: 2282,
124134
anyelement: 2283,
125135
_record: 2287,
126136
anynonarray: 2776,
137+
// deno-lint-ignore camelcase
127138
pg_authid: 2842,
139+
// deno-lint-ignore camelcase
128140
pg_auth_members: 2843,
141+
// deno-lint-ignore camelcase
129142
_txid_snapshot: 2949,
130143
uuid: 2950,
131144
_uuid: 2951,
145+
// deno-lint-ignore camelcase
132146
txid_snapshot: 2970,
147+
// deno-lint-ignore camelcase
133148
fdw_handler: 3115,
149+
// deno-lint-ignore camelcase
134150
pg_lsn: 3220,
151+
// deno-lint-ignore camelcase
135152
_pg_lsn: 3221,
153+
// deno-lint-ignore camelcase
136154
tsm_handler: 3310,
137155
anyenum: 3500,
138156
tsvector: 3614,
@@ -146,8 +164,10 @@ export const Oid = {
146164
regdictionary: 3769,
147165
_regdictionary: 3770,
148166
jsonb: 3802,
167+
// deno-lint-ignore camelcase
149168
jsonb_array: 3807,
150169
anyrange: 3831,
170+
// deno-lint-ignore camelcase
151171
event_trigger: 3838,
152172
int4range: 3904,
153173
_int4range: 3905,
@@ -161,6 +181,7 @@ export const Oid = {
161181
_daterange: 3913,
162182
int8range: 3926,
163183
_int8range: 3927,
184+
// deno-lint-ignore camelcase
164185
pg_shseclabel: 4066,
165186
regnamespace: 4089,
166187
_regnamespace: 4090,

packet_writer.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2626
*/
2727

28-
import { copyBytes } from "./deps.ts";
28+
import { copy } from "./deps.ts";
2929

3030
export class PacketWriter {
3131
private size: number;
@@ -49,7 +49,7 @@ export class PacketWriter {
4949
// https://stackoverflow.com/questions/2269063/buffer-growth-strategy
5050
const newSize = oldBuffer.length + (oldBuffer.length >> 1) + size;
5151
this.buffer = new Uint8Array(newSize);
52-
copyBytes(oldBuffer, this.buffer);
52+
copy(oldBuffer, this.buffer);
5353
}
5454
}
5555

@@ -76,7 +76,7 @@ export class PacketWriter {
7676
} else {
7777
const encodedStr = this.encoder.encode(string);
7878
this._ensure(encodedStr.byteLength + 1); // +1 for null terminator
79-
copyBytes(encodedStr, this.buffer, this.offset);
79+
copy(encodedStr, this.buffer, this.offset);
8080
this.offset += encodedStr.byteLength;
8181
}
8282

@@ -90,7 +90,7 @@ export class PacketWriter {
9090
}
9191

9292
this._ensure(1);
93-
copyBytes(this.encoder.encode(c), this.buffer, this.offset);
93+
copy(this.encoder.encode(c), this.buffer, this.offset);
9494
this.offset++;
9595
return this;
9696
}
@@ -99,14 +99,14 @@ export class PacketWriter {
9999
string = string || "";
100100
const encodedStr = this.encoder.encode(string);
101101
this._ensure(encodedStr.byteLength);
102-
copyBytes(encodedStr, this.buffer, this.offset);
102+
copy(encodedStr, this.buffer, this.offset);
103103
this.offset += encodedStr.byteLength;
104104
return this;
105105
}
106106

107107
add(otherBuffer: Uint8Array) {
108108
this._ensure(otherBuffer.length);
109-
copyBytes(otherBuffer, this.buffer, this.offset);
109+
copy(otherBuffer, this.buffer, this.offset);
110110
this.offset += otherBuffer.length;
111111
return this;
112112
}

test_deps.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ export * from "./deps.ts";
22
export {
33
assert,
44
assertEquals,
5-
assertStringContains,
65
assertThrows,
76
assertThrowsAsync,
8-
} from "https://deno.land/std@0.67.0/testing/asserts.ts";
7+
} from "https://deno.land/std@0.80.0/testing/asserts.ts";

tests/client.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const { test } = Deno;
22
import { Client, PostgresError } from "../mod.ts";
3-
import { assert, assertStringContains } from "../test_deps.ts";
3+
import { assert } from "../test_deps.ts";
44
import { TEST_CONNECTION_PARAMS } from "./constants.ts";
55

66
test("badAuthData", async function () {
@@ -15,7 +15,7 @@ test("badAuthData", async function () {
1515
} catch (e) {
1616
thrown = true;
1717
assert(e instanceof PostgresError);
18-
assertStringContains(e.message, "password authentication failed for user");
18+
assert(e.message.includes("password authentication failed for user"));
1919
} finally {
2020
await client.end();
2121
}

tests/data_types.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -269,17 +269,17 @@ testClient(async function bpcharNestedArray() {
269269
});
270270

271271
testClient(async function jsonArray() {
272-
const json_array = await CLIENT.query(
272+
const jsonArray = await CLIENT.query(
273273
`SELECT ARRAY_AGG(A) FROM (
274274
SELECT JSON_BUILD_OBJECT( 'X', '1' ) AS A
275275
UNION ALL
276276
SELECT JSON_BUILD_OBJECT( 'Y', '2' ) AS A
277277
) A`,
278278
);
279279

280-
assertEquals(json_array.rows[0][0], [{ X: "1" }, { Y: "2" }]);
280+
assertEquals(jsonArray.rows[0][0], [{ X: "1" }, { Y: "2" }]);
281281

282-
const json_array_nested = await CLIENT.query(
282+
const jsonArrayNested = await CLIENT.query(
283283
`SELECT ARRAY[ARRAY[ARRAY_AGG(A), ARRAY_AGG(A)], ARRAY[ARRAY_AGG(A), ARRAY_AGG(A)]] FROM (
284284
SELECT JSON_BUILD_OBJECT( 'X', '1' ) AS A
285285
UNION ALL
@@ -288,7 +288,7 @@ testClient(async function jsonArray() {
288288
);
289289

290290
assertEquals(
291-
json_array_nested.rows[0][0],
291+
jsonArrayNested.rows[0][0],
292292
[
293293
[
294294
[{ X: "1" }, { Y: "2" }],

0 commit comments

Comments
 (0)