diff --git a/firebase-vscode/package.json b/firebase-vscode/package.json index 197820d5340..b9dd9d1a5d1 100644 --- a/firebase-vscode/package.json +++ b/firebase-vscode/package.json @@ -80,14 +80,6 @@ } } }, - "keybindings": [ - { - "command": "firebase.dataConnect.executeOperationAtCursor", - "key": "ctrl+enter", - "mac": "cmd+enter", - "when": "editorLangId == gql || editorLangId == graphql" - } - ], "viewsContainers": { "activitybar": [ { diff --git a/src/emulator/dataconnect/pgliteServer.ts b/src/emulator/dataconnect/pgliteServer.ts index 642b6b578a3..3550ff859ad 100644 --- a/src/emulator/dataconnect/pgliteServer.ts +++ b/src/emulator/dataconnect/pgliteServer.ts @@ -17,6 +17,17 @@ import { } from "./pg-gateway/index"; import { fromNodeSocket } from "./pg-gateway/platforms/node"; import { logger } from "../../logger"; +export const TRUNCATE_TABLES_SQL = ` +DO $do$ +BEGIN + EXECUTE + (SELECT 'TRUNCATE TABLE ' || string_agg(oid::regclass::text, ', ') || ' CASCADE' + FROM pg_class + WHERE relkind = 'r' + AND relnamespace = 'public'::regnamespace + ); +END +$do$;`; export class PostgresServer { private username: string; @@ -95,17 +106,7 @@ export class PostgresServer { public async clearDb(): Promise { const db = await this.getDb(); - await db.query(` -DO $do$ -BEGIN - EXECUTE - (SELECT 'TRUNCATE TABLE ' || string_agg(oid::regclass::text, ', ') || ' CASCADE' - FROM pg_class - WHERE relkind = 'r' - AND relnamespace = 'public'::regnamespace - ); -END -$do$;`); + await db.query(TRUNCATE_TABLES_SQL); } public async exportData(exportPath: string): Promise { diff --git a/src/emulator/dataconnectEmulator.ts b/src/emulator/dataconnectEmulator.ts index 4a8aa1d900d..e60d8b5f615 100644 --- a/src/emulator/dataconnectEmulator.ts +++ b/src/emulator/dataconnectEmulator.ts @@ -1,4 +1,5 @@ import * as childProcess from "child_process"; +import * as pg from "pg"; import { EventEmitter } from "events"; import * as clc from "colorette"; import * as path from "path"; @@ -17,7 +18,7 @@ import { EmulatorRegistry } from "./registry"; import { logger } from "../logger"; import { load } from "../dataconnect/load"; import { Config } from "../config"; -import { PostgresServer } from "./dataconnect/pgliteServer"; +import { PostgresServer, TRUNCATE_TABLES_SQL } from "./dataconnect/pgliteServer"; import { cleanShutdown } from "./controller"; import { connectableHostname } from "../utils"; @@ -180,6 +181,9 @@ export class DataConnectEmulator implements EmulatorInstance { async clearData(): Promise { if (this.postgresServer) { await this.postgresServer.clearDb(); + } else { + const conn = new pg.Client(dataConnectLocalConnString()); + conn.query(TRUNCATE_TABLES_SQL); } } diff --git a/src/emulator/types.ts b/src/emulator/types.ts index 8492026cf85..516d63c3ed9 100644 --- a/src/emulator/types.ts +++ b/src/emulator/types.ts @@ -37,7 +37,7 @@ export const DOWNLOADABLE_EMULATORS = [ Emulators.DATACONNECT, ]; -export type ImportExportEmulators = Emulators.FIRESTORE | Emulators.DATABASE | Emulators.AUTH; +export type ImportExportEmulators = Emulators.FIRESTORE | Emulators.DATABASE | Emulators.AUTH | Emulators.STORAGE | Emulators.DATACONNECT; export const IMPORT_EXPORT_EMULATORS = [ Emulators.FIRESTORE, Emulators.DATABASE,