Skip to content
This repository has been archived by the owner on Jul 14, 2023. It is now read-only.

Add schema handling to connector #44

Merged
merged 7 commits into from
Nov 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ For local development you can provide the credentials in the file `default-env.j
"port": "5432",
"database": "dbname",
"user": "postgres",
"password": "postgres"
"password": "postgres",
"schema":"public"
}
}
]
Expand Down
5 changes: 5 additions & 0 deletions lib/pg/Service.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ module.exports = class PostgresDatabase extends cds.DatabaseService {
}
this._pool = new Pool(this.options.credentials)

// SET SCHEMA
if (this.options.credentials && this.options.credentials.schema) {
this._pool.query(`SET search_path TO '${this.options.credentials.schema}';`)
}

// Mapping of the pg specific executions. Inspired by the SQLite and HANA adapters.
// We call the default run handlers but pass in our custom execution functions.
this._execute = execute
Expand Down