MCPcopy Index your code
hub / github.com/outerbase/studio / PostgresLikeDriver

Class PostgresLikeDriver

src/drivers/postgres/postgres-driver.ts:64–438  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

62}
63
64export default class PostgresLikeDriver extends CommonSQLImplement {
65 constructor(protected _db: QueryableBaseDriver) {
66 super();
67 }
68
69 query(stmt: string): Promise<DatabaseResultSet> {
70 return this._db.query(stmt);
71 }
72
73 transaction(stmts: string[]): Promise<DatabaseResultSet[]> {
74 return this._db.transaction(stmts);
75 }
76
77 batch(stmts: string[]): Promise<DatabaseResultSet[]> {
78 return this._db.batch ? this._db.batch(stmts) : super.batch(stmts);
79 }
80
81 close(): void {
82 // Do nothing
83 }
84
85 columnTypeSelector: ColumnTypeSelector = POSTGRES_DATA_TYPE_SUGGESTION;
86
87 escapeId(id: string) {
88 return `"${id.replace(/"/g, '""')}"`;
89 }
90
91 escapeValue(value: unknown): string {
92 return escapeSqlValue(value);
93 }
94
95 getFlags(): DriverFlags {
96 return {
97 defaultSchema: "public",
98 dialect: "postgres",
99 optionalSchema: false,
100 supportRowId: false,
101 supportBigInt: false,
102 supportModifyColumn: true,
103 supportCreateUpdateTable: true,
104 supportCreateUpdateDatabase: false,
105 supportInsertReturning: true,
106 supportUpdateReturning: true,
107 supportCreateUpdateTrigger: false,
108 supportUseStatement: true,
109 };
110 }
111
112 async getCurrentSchema(): Promise<string | null> {
113 const result = (await this.query("SHOW search_path")) as unknown as {
114 rows: { search_path?: string | null }[];
115 };
116
117 const db = result.rows[0].search_path!.split(",")[0];
118
119 return db === this.escapeId("$user") ? "public" : db;
120 }
121

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…