Skip to content

Commit

Permalink
Fix Connect and Inspect with CDS output
Browse files Browse the repository at this point in the history
  • Loading branch information
jung-thomas committed Mar 22, 2022
1 parent e50a609 commit 8058cc4
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 16 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
[
{
"date": "2022-03-22",
"version": "3.202203.2",
"Changed": [
"Fix for connect and incorrect options format for hdb module",
"CDS output escape quotes within comments"
]
},
{
"date": "2022-03-11",
"version": "3.202203.1",
Expand Down
26 changes: 12 additions & 14 deletions bin/connect.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,12 @@ export function handler(argv) {
export async function dbConnect(input) {
base.debug(`dbConnect`)
try {
input.admin = true
base.setPrompts(input)
let options = {};
options.pooling = true;
options.encrypt = input.encrypt;
options.serverNode = input.userstorekey || input.connection;
let options = {}
options.pooling = true
options.encrypt = input.encrypt
options.serverNode = input.userstorekey || input.connection
if (!input.userstorekey) { options.user = input.user }
if (!input.userstorekey) { options.password = input.password }
options.sslValidateCertificate = false
Expand All @@ -114,17 +115,17 @@ export async function dbConnect(input) {
}
base.debug(options)

const db = await base.createDBConnection(options)
if (input.save) {
await saveEnv(options)
}
const db = await base.createDBConnection()

let results = await db.execSQL(`SELECT CURRENT_USER AS "Current User", CURRENT_SCHEMA AS "Current Schema" FROM DUMMY`)
base.outputTable(results)

let resultsSession = await db.execSQL(`SELECT * FROM M_SESSION_CONTEXT WHERE CONNECTION_ID = (SELECT SESSION_CONTEXT('CONN_ID') FROM "DUMMY")`)
base.outputTable(resultsSession)

if (input.save) {
await saveEnv(options)
}
return base.end()
} catch (error) {
base.error(error)
Expand Down Expand Up @@ -164,10 +165,7 @@ export async function saveEnv(options) {
defaultEnv.VCAP_SERVICES.hana[0].credentials.sslCryptoProvider = 'openssl'
defaultEnv.VCAP_SERVICES.hana[0].credentials.sslValidateCertificate = true
}
fs.writeFile("default-env-admin.json", JSON.stringify(defaultEnv, null, '\t'), (err) => {
if (err) {
throw new Error(`${base.bundle.getText("errConn")} ${JSON.stringify(err)}`)
}
console.log(base.bundle.getText("adminSaved"))
})
fs.writeFileSync("default-env-admin.json", JSON.stringify(defaultEnv, null, '\t'))
console.log(base.bundle.getText("adminSaved"))

}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hana-cli",
"version": "3.202203.1",
"version": "3.202203.2",
"description": "HANA Developer Command Line Interface",
"main": "index.js",
"bin": {
Expand Down
2 changes: 1 addition & 1 deletion utils/dbInspect.js
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ export async function formatCDS(db, object, fields, constraints, type, parent) {
// }
}
if (field.COMMENTS) {
cdstable += ` @title: '${field.COLUMN_NAME}: ${field.COMMENTS}' `
cdstable += ` @title: '${field.COLUMN_NAME}: ${field.COMMENTS.replace(/[']/g, "'$&")}' `
} else {
cdstable += ` @title: '${field.COLUMN_NAME}' `
}
Expand Down

0 comments on commit 8058cc4

Please sign in to comment.