Skip to content

Commit c3c679e

Browse files
committed
Merge remote-tracking branch 'origin/master' into feat/auto-init-inject-emulator-envs
2 parents c4d3afa + 0265a79 commit c3c679e

File tree

4 files changed

+8
-18
lines changed

4 files changed

+8
-18
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- Fixed an issue where `clearData` with no tables would cause the Data Connect emulator to crash.
2+
- Fixed an issue where the Data Connect emulator would crash with `Error: Unreachable`.

src/emulator/controller.ts

+1
Original file line numberDiff line numberDiff line change
@@ -884,6 +884,7 @@ export async function startAll(
884884
postgresListen: listenForEmulator["dataconnect.postgres"],
885885
enable_output_generated_sdk: true, // TODO: source from arguments
886886
enable_output_schema_extensions: true,
887+
debug: options.debug,
887888
};
888889

889890
if (exportMetadata.dataconnect) {

src/emulator/dataconnect/pgliteServer.ts

+5-16
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,18 @@ import { hasMessage } from "../../error";
2121

2222
export const TRUNCATE_TABLES_SQL = `
2323
DO $do$
24+
DECLARE _clear text;
2425
BEGIN
25-
EXECUTE
26-
(SELECT 'TRUNCATE TABLE ' || string_agg(oid::regclass::text, ', ') || ' CASCADE'
26+
SELECT 'TRUNCATE TABLE ' || string_agg(oid::regclass::text, ', ') || ' CASCADE'
2727
FROM pg_class
2828
WHERE relkind = 'r'
2929
AND relnamespace = 'public'::regnamespace
30-
);
30+
INTO _clear;
31+
EXECUTE COALESCE(_clear, 'select now()');
3132
END
3233
$do$;`;
3334

3435
export class PostgresServer {
35-
private username: string;
36-
private database: string;
3736
private dataDirectory?: string;
3837
private importPath?: string;
3938
private debug: DebugLevel;
@@ -89,8 +88,6 @@ export class PostgresServer {
8988
const vector = (await dynamicImport("@electric-sql/pglite/vector")).vector;
9089
const uuidOssp = (await dynamicImport("@electric-sql/pglite/contrib/uuid_ossp")).uuid_ossp;
9190
const pgliteArgs: PGliteOptions = {
92-
username: this.username,
93-
database: this.database,
9491
debug: this.debug,
9592
extensions: {
9693
vector,
@@ -147,15 +144,7 @@ export class PostgresServer {
147144
return;
148145
}
149146

150-
constructor(args: {
151-
database: string;
152-
username: string;
153-
dataDirectory?: string;
154-
importPath?: string;
155-
debug?: boolean;
156-
}) {
157-
this.username = args.username;
158-
this.database = args.database;
147+
constructor(args: { dataDirectory?: string; importPath?: string; debug?: boolean }) {
159148
this.dataDirectory = args.dataDirectory;
160149
this.importPath = args.importPath;
161150
this.debug = args.debug ? 5 : 0;

src/emulator/dataconnectEmulator.ts

-2
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,6 @@ export class DataConnectEmulator implements EmulatorInstance {
118118
? path.join(this.args.importPath, "postgres.tar.gz")
119119
: undefined;
120120
this.postgresServer = new PostgresServer({
121-
database: dbId,
122-
username: "fdc",
123121
dataDirectory,
124122
importPath: postgresDumpPath,
125123
debug: this.args.debug,

0 commit comments

Comments
 (0)