Socket
Socket
Sign inDemoInstall

@sap/cds-hana

Package Overview
Dependencies
Maintainers
3
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sap/cds-hana - npm Package Compare versions

Comparing version 1.21.0 to 1.24.0

npm-shrinkwrap.json

23

CHANGELOG.md

@@ -9,2 +9,25 @@ # Changelog

## Version 1.24.0 - 2020-02-26
### Added
- Streaming from draft
## Version 1.23.0 - 2020-02-19
### Changed
- Use `like` instead of `contains` fuzzy search for `$search` queries
## Version 1.22.0 - 2020-02-05
### Added
- Implement statement drop
### Changed
- SESSION_CONTEXT('APPLICATIONUSER') instead of SESSION_CONTEXT('XS_APPLICATIONUSER')
- @sap/hana-client is preferred over hdb
## Version 1.21.0 - 2019-12-10

@@ -11,0 +34,0 @@

24

lib/cds.js
const injection = {
inject (cds) {
if (!cds || typeof cds !== 'object') {
throw new Error('Injected value is not of type `cds`')
cds: global.cds,
inject (cds, force = false) {
if (force || !injection.cds) {
if (!cds || typeof cds !== 'object') {
throw new Error('Injected value is not of type `cds`')
}
injection.cds = cds
}
injection.cds = cds
require('@sap/cds-sql').inject(cds)
require('@sap/cds-sql').inject(injection.cds, force)
}

@@ -21,10 +24,3 @@ }

if (!injection.cds) {
if (name === 'config') {
return { data: {} }
}
throw new Error('This method requires `cds` to be injected')
}
if (name === 'config' && !target.cds.config) {
if (name === 'config' && (!target.cds || !target.cds.config)) {
return { data: {} }

@@ -31,0 +27,0 @@ }

@@ -21,2 +21,4 @@ const hanaClient = require('./hanaClient')

const ensureNoDraftsSuffix = name => (name.endsWith('_drafts') ? name.slice(0, -7) : name)
class Client extends BaseClient {

@@ -251,3 +253,3 @@ /**

return Object.keys(update.data).some(key => {
const entity = csn.definitions[update.entity]
const entity = csn.definitions[ensureNoDraftsSuffix(update.entity)]
if (entity) {

@@ -266,3 +268,3 @@ const element = entity.elements[key]

if (insert.columns) {
const into = csn.definitions[insert.into]
const into = csn.definitions[ensureNoDraftsSuffix(insert.into)]
if (into) {

@@ -283,3 +285,3 @@ for (const key of insert.columns) {

if (insert.entries && insert.entries.length > 0) {
const into = csn.definitions[insert.into]
const into = csn.definitions[ensureNoDraftsSuffix(insert.into)]
if (into) {

@@ -333,3 +335,3 @@ for (const key of Object.keys(insert.entries[0])) {

convertErrorCodeToString(err)
err.failedQuery = sql
err.query = sql
return reject(err)

@@ -390,3 +392,3 @@ }

convertErrorCodeToString(err)
err.failedQuery = sql
err.query = sql
return reject(err)

@@ -478,3 +480,3 @@ }

convertErrorCodeToString(err)
err.failedQuery = sql
err.query = sql

@@ -484,3 +486,3 @@ return reject(err)

resolve(new HdbStatement(statement, sql, this._hanaStream))
resolve(new HdbStatement(statement, sql, this._hanaStream, true))
}

@@ -491,3 +493,9 @@

} else {
this._dbc.prepare(sql, cb)
try {
this._dbc.prepare(sql, cb)
} catch (err) {
convertErrorCodeToString(err)
err.query = sql
return reject(err)
}
}

@@ -544,3 +552,3 @@ })

this.setSessionContext('XS_APPLICATIONUSER', this._user)
this.setSessionContext('APPLICATIONUSER', this._user)
}

@@ -547,0 +555,0 @@

@@ -7,5 +7,5 @@ let error

} catch (err) {
if (name === 'hdb') {
if (name === '@sap/hana-client') {
error = err
return _getClient('@sap/hana-client')
return _getClient('hdb')
}

@@ -17,2 +17,2 @@

module.exports = _getClient('hdb')
module.exports = _getClient('@sap/hana-client')

@@ -10,7 +10,9 @@ const { convertErrorCodeToString } = require('../util')

* @param {object} hanaStream - hanaStream object if using hana-client
* @param {boolean} autoDrop - Determines whether statement should be dropped automatically after execute. Defaults to false.
*/
constructor (statement, sql, hanaStream) {
constructor (statement, sql, hanaStream, autoDrop = false) {
this._stmt = statement
this._sql = sql
this._hanaStream = hanaStream
this._autoDrop = autoDrop
}

@@ -43,3 +45,4 @@

convertErrorCodeToString(err)
err.failedQuery = this._sql
err.query = this._sql
this._dropIfSpecified()

@@ -66,2 +69,3 @@ return reject(err)

} else {
this._dropIfSpecified()
resolve(result)

@@ -73,2 +77,15 @@ }

/**
* Manually drop the prepared statement. Should be used, for instance, when autoDrop is set to false.
*/
drop () {
this._stmt.drop()
}
_dropIfSpecified () {
if (this._autoDrop) {
this.drop()
}
}
_getReadObjectHdb (result, rows) {

@@ -82,2 +99,8 @@ return () => {

row[key] = row[key].createReadStream()
row[key].on('end', () => {
this._dropIfSpecified()
})
row[key].on('error', () => {
this._dropIfSpecified()
})
}

@@ -122,2 +145,8 @@ }

res[columnInfo[i].name] = this._hanaStream.createLobStream(result, i, { readSize: 1024000 })
res[columnInfo[i].name].on('end', () => {
this._dropIfSpecified()
})
res[columnInfo[i].name].on('error', () => {
this._dropIfSpecified()
})
} else {

@@ -124,0 +153,0 @@ res[columnInfo[i].name] = result.getValue(i)

@@ -1,1 +0,1 @@

{"bundleDependencies":false,"dependencies":{"@sap/cds-sql":"1.21.0"},"deprecated":false,"description":"Driver package for access to hana database, including setting up the client, configuring all the necessary options to initiate the connection and handling database specifics so that they can be processed on our end.","engines":{"node":">= 8.9.0"},"husky":{"hooks":{"pre-commit":"lint-staged"}},"lint-staged":{"{lib,test}/**/*.js":["prettier-standard","standard --fix","git add"]},"main":"lib/index.js","name":"@sap/cds-hana","version":"1.21.0","license":"SEE LICENSE IN developer-license-3.1.txt"}
{"bundleDependencies":false,"dependencies":{"@sap/cds-sql":"^1.23.2"},"deprecated":false,"description":"Driver package for access to hana database, including setting up the client, configuring all the necessary options to initiate the connection and handling database specifics so that they can be processed on our end.","engines":{"node":">= 8.9.0"},"husky":{"hooks":{"pre-commit":"lint-staged"}},"lint-staged":{"{lib,test}/**/*.js":["prettier-standard","standard --fix","git add"]},"main":"lib/index.js","name":"@sap/cds-hana","version":"1.24.0","license":"SEE LICENSE IN developer-license-3.1.txt"}

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc