Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into feat/auto-init-inje…
Browse files Browse the repository at this point in the history
…ct-emulator-envs
  • Loading branch information
mathu97 committed Dec 13, 2024
2 parents c4d3afa + 0265a79 commit c3c679e
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 18 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Fixed an issue where `clearData` with no tables would cause the Data Connect emulator to crash.
- Fixed an issue where the Data Connect emulator would crash with `Error: Unreachable`.
1 change: 1 addition & 0 deletions src/emulator/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -884,6 +884,7 @@ export async function startAll(
postgresListen: listenForEmulator["dataconnect.postgres"],
enable_output_generated_sdk: true, // TODO: source from arguments
enable_output_schema_extensions: true,
debug: options.debug,
};

if (exportMetadata.dataconnect) {
Expand Down
21 changes: 5 additions & 16 deletions src/emulator/dataconnect/pgliteServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,18 @@ import { hasMessage } from "../../error";

export const TRUNCATE_TABLES_SQL = `
DO $do$
DECLARE _clear text;
BEGIN
EXECUTE
(SELECT 'TRUNCATE TABLE ' || string_agg(oid::regclass::text, ', ') || ' CASCADE'
SELECT 'TRUNCATE TABLE ' || string_agg(oid::regclass::text, ', ') || ' CASCADE'
FROM pg_class
WHERE relkind = 'r'
AND relnamespace = 'public'::regnamespace
);
INTO _clear;
EXECUTE COALESCE(_clear, 'select now()');
END
$do$;`;

export class PostgresServer {
private username: string;
private database: string;
private dataDirectory?: string;
private importPath?: string;
private debug: DebugLevel;
Expand Down Expand Up @@ -89,8 +88,6 @@ export class PostgresServer {
const vector = (await dynamicImport("@electric-sql/pglite/vector")).vector;
const uuidOssp = (await dynamicImport("@electric-sql/pglite/contrib/uuid_ossp")).uuid_ossp;
const pgliteArgs: PGliteOptions = {
username: this.username,
database: this.database,
debug: this.debug,
extensions: {
vector,
Expand Down Expand Up @@ -147,15 +144,7 @@ export class PostgresServer {
return;
}

constructor(args: {
database: string;
username: string;
dataDirectory?: string;
importPath?: string;
debug?: boolean;
}) {
this.username = args.username;
this.database = args.database;
constructor(args: { dataDirectory?: string; importPath?: string; debug?: boolean }) {
this.dataDirectory = args.dataDirectory;
this.importPath = args.importPath;
this.debug = args.debug ? 5 : 0;
Expand Down
2 changes: 0 additions & 2 deletions src/emulator/dataconnectEmulator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,6 @@ export class DataConnectEmulator implements EmulatorInstance {
? path.join(this.args.importPath, "postgres.tar.gz")
: undefined;
this.postgresServer = new PostgresServer({
database: dbId,
username: "fdc",
dataDirectory,
importPath: postgresDumpPath,
debug: this.args.debug,
Expand Down

0 comments on commit c3c679e

Please sign in to comment.