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

Add support for Managed, Virtual, Key and null checks #46

Merged
merged 10 commits into from
Nov 17, 2020
11 changes: 6 additions & 5 deletions lib/pg/Service.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,8 @@ module.exports = class PostgresDatabase extends cds.DatabaseService {
// "flattens" the query
// and "redirects" modification statements (CUD) from view to actual table
this.before(['CREATE', 'UPDATE'], '*', dateTime) // > has to run before rewrite

// TODO: Where to move this?
//this.before(['CREATE', 'UPDATE'], '*', keys)
//this.before(['CREATE', 'UPDATE'], '*', managed)
//this.before(['CREATE', 'UPDATE'], '*', virtual)
// VIRTUAL, MANAGED, Keys and null checks
this.before(['CREATE', 'UPDATE'], '*', this._input)

this.before(['CREATE', 'READ', 'UPDATE', 'DELETE'], '*', rewrite)
//this.before(['CREATE', 'READ', 'UPDATE', 'DELETE'], '*', this.setModel)
Expand Down Expand Up @@ -164,6 +161,10 @@ module.exports = class PostgresDatabase extends cds.DatabaseService {
async acquire(arg) {
// const tenant = (typeof arg === 'string' ? arg : arg.user.tenant) || 'anonymous'
const dbc = await this._pool.connect()
// SET SCHEMA
if (this.options.credentials && this.options.credentials.schema) {
vobu marked this conversation as resolved.
Show resolved Hide resolved
dbc.query(`SET search_path TO '${this.options.credentials.schema}';`)
}
return dbc
}

Expand Down