Socket
Socket
Sign inDemoInstall

@cap-js/hana

Package Overview
Dependencies
Maintainers
2
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cap-js/hana - npm Package Compare versions

Comparing version 0.0.5 to 0.0.6

13

CHANGELOG.md

@@ -7,2 +7,15 @@ # Changelog

## [0.0.6](https://github.com/cap-js/cds-dbs/compare/hana-v0.0.5...hana-v0.0.6) (2024-02-28)
### Added
* cds.Vector support for the HANAService ([#442](https://github.com/cap-js/cds-dbs/issues/442)) ([1057a13](https://github.com/cap-js/cds-dbs/commit/1057a13a9297cb1720b6faaf107bb3116a8c4a3e))
### Fixed
* `TypeError` for `cds bind` in MTX scenario ([#482](https://github.com/cap-js/cds-dbs/issues/482)) ([38722fe](https://github.com/cap-js/cds-dbs/commit/38722fe7d7df9b2c9d622e969d528be205df383a))
* Allow SELECT.join queries again with full infer call ([#469](https://github.com/cap-js/cds-dbs/issues/469)) ([5329ec0](https://github.com/cap-js/cds-dbs/commit/5329ec0a25036a1e42513e8bb9347b0ff8c7aa2d))
## [0.0.5](https://github.com/cap-js/cds-dbs/compare/hana-v0.0.4...hana-v0.0.5) (2024-02-16)

@@ -9,0 +22,0 @@

52

lib/HANAService.js

@@ -32,3 +32,3 @@ const fs = require('fs')

get factory() {
const driver = drivers[this.options.driver || this.options.credentials.driver]?.driver || drivers.default.driver
const driver = drivers[this.options.driver || this.options.credentials?.driver]?.driver || drivers.default.driver
const isMultitenant = 'multiTenant' in this.options ? this.options.multiTenant : cds.env.requires.multitenancy

@@ -104,2 +104,5 @@ const service = this

const { query, data } = req
if (!query.target) {
try { this.infer(query) } catch (e) { /**/ }
}
if (!query.target || query.target._unresolved) {

@@ -130,12 +133,12 @@ return super.onSELECT(req)

try {
const { sql, entries, cqn } = this.cqn2sql(query, data)
if (!sql) return // Do nothing when there is nothing to be done
const ps = await this.prepare(sql)
// HANA driver supports batch execution
const results = await (entries
? HANAVERSION <= 2
? entries.reduce((l, c) => l.then(() => ps.run(c)), Promise.resolve(0))
: ps.run(entries[0])
: ps.run())
return new this.class.InsertResults(cqn, results)
const { sql, entries, cqn } = this.cqn2sql(query, data)
if (!sql) return // Do nothing when there is nothing to be done
const ps = await this.prepare(sql)
// HANA driver supports batch execution
const results = await (entries
? HANAVERSION <= 2
? entries.reduce((l, c) => l.then(() => ps.run(c)), Promise.resolve(0))
: ps.run(entries[0])
: ps.run())
return new this.class.InsertResults(cqn, results)
} catch (err) {

@@ -818,13 +821,13 @@ throw _not_unique(err, 'ENTITY_ALREADY_EXISTS')

list(list) {
const first = list.list[0]
// If the list only contains of lists it is replaced with a json function and a placeholder
if (this.values && first.list && !first.list.find(v => !v.val)) {
const extraction = first.list.map((v, i) => `"${i}" ${this.constructor.InsertTypeMap[typeof v.val]()} PATH '$.V${i}'`)
this.values.push(JSON.stringify(list.list.map(l => l.list.reduce((l, c, i) => { l[`V${i}`] = c.val; return l }, {}))))
return `(SELECT * FROM JSON_TABLE(?, '$' COLUMNS(${extraction})))`
}
// Call super for normal SQL behavior
return super.list(list)
}
list(list) {
const first = list.list[0]
// If the list only contains of lists it is replaced with a json function and a placeholder
if (this.values && first.list && !first.list.find(v => !v.val)) {
const extraction = first.list.map((v, i) => `"${i}" ${this.constructor.InsertTypeMap[typeof v.val]()} PATH '$.V${i}'`)
this.values.push(JSON.stringify(list.list.map(l => l.list.reduce((l, c, i) => { l[`V${i}`] = c.val; return l }, {}))))
return `(SELECT * FROM JSON_TABLE(?, '$' COLUMNS(${extraction})))`
}
// Call super for normal SQL behavior
return super.list(list)
}

@@ -937,4 +940,5 @@ quote(s) {

array: () => `NVARCHAR(2147483647)`,
Vector: () => `NVARCHAR(2147483647)`,
// Javascript types
// JavaScript types
string: () => `NVARCHAR(2147483647)`,

@@ -952,2 +956,3 @@ number: () => `DOUBLE`

Boolean: e => `CASE WHEN ${e} = 'true' THEN TRUE WHEN ${e} = 'false' THEN FALSE END`,
Vector: e => `TO_REAL_VECTOR(${e})`,
}

@@ -963,2 +968,3 @@

Timestamp: e => `to_char(${e}, 'YYYY-MM-DD"T"HH24:MI:SS.FF3"Z"')`,
Vector: e => `TO_NVARCHAR(${e})`,
}

@@ -965,0 +971,0 @@ }

{
"name": "@cap-js/hana",
"version": "0.0.5",
"version": "0.0.6",
"description": "CDS database service for SAP HANA",

@@ -5,0 +5,0 @@ "homepage": "https://cap.cloud.sap/",

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