@yydb/postgresql 0.0.12 → 0.0.14

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.
Files changed (2) hide show
  1. package/bin/psql.mjs +23 -11
  2. package/package.json +6 -6
package/bin/psql.mjs CHANGED
@@ -31,13 +31,15 @@ function argumentsFor(args) {
31
31
  }
32
32
  if (option === "-F" || option === "--field-separator") {
33
33
  const value = args[++index];
34
- if (value === undefined || value.includes("\0")) throw new Error(`invalid value for ${option}`);
34
+ if (value === undefined || value.includes("\0"))
35
+ throw new Error(`invalid value for ${option}`);
35
36
  options.separator = value;
36
37
  continue;
37
38
  }
38
39
  if (option === "-P" || option === "--pset") {
39
40
  const value = args[++index];
40
- if (value === undefined || !value.startsWith("null=")) throw new Error("only psql null output is configurable");
41
+ if (value === undefined || !value.startsWith("null="))
42
+ throw new Error("only psql null output is configurable");
41
43
  options.nullValue = value.slice(5);
42
44
  continue;
43
45
  }
@@ -174,7 +176,8 @@ function query(options) {
174
176
  )
175
177
  throw new Error("invalid ReadyForQuery");
176
178
  if (started) {
177
- if (currentResult !== null) throw new Error("PostgreSQL result ended before CommandComplete");
179
+ if (currentResult !== null)
180
+ throw new Error("PostgreSQL result ended before CommandComplete");
178
181
  finish();
179
182
  return;
180
183
  }
@@ -184,14 +187,19 @@ function query(options) {
184
187
  throw new Error("PostgreSQL query exceeds byte limit");
185
188
  socket.write(message("Q", sql));
186
189
  } else if (tag === "T") {
187
- if (!started || currentResult !== null) throw new Error("unexpected PostgreSQL RowDescription");
190
+ if (!started || currentResult !== null)
191
+ throw new Error("unexpected PostgreSQL RowDescription");
188
192
  currentResult = { columns: columnsFrom(payload), rows: [], tag: "" };
189
193
  } else if (tag === "D") {
190
- if (!started || currentResult === null) throw new Error("DataRow without RowDescription");
194
+ if (!started || currentResult === null)
195
+ throw new Error("DataRow without RowDescription");
191
196
  currentResult.rows.push(rowFrom(payload, currentResult.columns.length));
192
- }
193
- else if (tag === "C") {
194
- if (!started || payload.length < 2 || payload.indexOf(0) !== payload.length - 1)
197
+ } else if (tag === "C") {
198
+ if (
199
+ !started ||
200
+ payload.length < 2 ||
201
+ payload.indexOf(0) !== payload.length - 1
202
+ )
195
203
  throw new Error("invalid CommandComplete");
196
204
  const result = currentResult ?? { columns: [], rows: [], tag: "" };
197
205
  result.tag = payload.toString("utf8", 0, payload.length - 1);
@@ -218,14 +226,18 @@ async function main(args) {
218
226
  return;
219
227
  }
220
228
  if (args.length === 1 && args[0] === "--help") {
221
- console.log("Usage: psql [-h HOST] [-p PORT] [-U USER] [-d DATABASE] [-t] [-F SEP] [-P null=TEXT] -c SQL");
229
+ console.log(
230
+ "Usage: psql [-h HOST] [-p PORT] [-U USER] [-d DATABASE] [-t] [-F SEP] [-P null=TEXT] -c SQL",
231
+ );
222
232
  return;
223
233
  }
224
234
  const options = argumentsFor(args);
225
235
  const results = await query(options);
226
236
  for (const result of results) {
227
- if (options.headers && result.columns.length) console.log(result.columns.join(options.separator));
228
- for (const row of result.rows) console.log(row.map((value) => value ?? options.nullValue).join(options.separator));
237
+ if (options.headers && result.columns.length)
238
+ console.log(result.columns.join(options.separator));
239
+ for (const row of result.rows)
240
+ console.log(row.map((value) => value ?? options.nullValue).join(options.separator));
229
241
  if (result.columns.length === 0 && options.headers) console.log(result.tag);
230
242
  }
231
243
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yydb/postgresql",
3
- "version": "0.0.12",
3
+ "version": "0.0.14",
4
4
  "description": "Pretend you installed PostgreSQL. YYDS scripting runtime underneath.",
5
5
  "license": "MPL-2.0",
6
6
  "type": "module",
@@ -18,8 +18,8 @@
18
18
  }
19
19
  },
20
20
  "bin": {
21
- "psql": "./bin/psql.mjs",
22
- "postgres": "./bin/postgres.mjs"
21
+ "psql": "bin/psql.mjs",
22
+ "postgres": "bin/postgres.mjs"
23
23
  },
24
24
  "files": [
25
25
  "bin",
@@ -33,9 +33,9 @@
33
33
  "repository": {
34
34
  "type": "git",
35
35
  "url": "git+https://github.com/yy-database/yyds.git",
36
- "directory": "projects/packages/postgresql"
36
+ "directory": "projects/yyds.ts/emulators/postgresql"
37
37
  },
38
- "homepage": "https://github.com/yy-database/yyds/tree/dev/projects/packages/postgresql#readme",
38
+ "homepage": "https://github.com/yy-database/yyds/tree/dev/projects/yyds.ts/emulators/postgresql#readme",
39
39
  "bugs": {
40
40
  "url": "https://github.com/yy-database/yyds/issues"
41
41
  },
@@ -49,7 +49,7 @@
49
49
  "access": "public"
50
50
  },
51
51
  "dependencies": {
52
- "@yydb/yyds": "0.0.12"
52
+ "@yydb/yyds": "0.0.14"
53
53
  },
54
54
  "devDependencies": {
55
55
  "@types/node": "^22.15.0",