Commit 5fe1969e authored by Pavel Mashliakovskiy's avatar Pavel Mashliakovskiy 🤹🏻

Merge branch 'feature/skipSelectBeforeUpdate' into 'master'

documentation and test for `__skipSelectBeforeUpdate` `CustomRepository.misc`...

See merge request !822
parents bfb986b7 f63acd14
Pipeline #21717 skipped with stage
......@@ -36,6 +36,7 @@ module.exports = function runMixinsTests (options) {
console.debug('test asterisk in UBQL')
testAsterisk(conn)
}
testSkipSelectBeforeUpdate(conn)
}
/**
......@@ -270,3 +271,36 @@ function testAsterisk (conn) {
q.version = '-1'
conn.query(q)
}
/**
* @param {SyncConnection} conn
*/
function testSkipSelectBeforeUpdate (conn) {
console.debug('Test __skipSelectBeforeUpdate')
const ID = conn.insert({
entity: 'tst_IDMapping',
fieldList: ['ID'],
execParams: {
code: 'testSkipSelectBeforeUpdate'
}
})
conn.update({
entity: 'tst_IDMapping',
__skipSelectBeforeUpdate: true,
execParams: {
ID,
code: 'testSkipSelectBeforeUpdate2'
}
})
const serverSideUpdate = `const store = UB.DataStore('tst_IDMapping')
store.run('update', {
__skipSelectBeforeUpdate: true,
execParams: {
ID: ${ID},
code: 'testSkipSelectBeforeUpdate3'
}
})`
conn.post('evaluateScript', serverSideUpdate)
const updatedCode = conn.Repository('tst_IDMapping').attrs('code').where('ID', '=', ID).selectScalar()
assert.strictEqual(updatedCode, 'testSkipSelectBeforeUpdate3', 'Should update on server side while __skipSelectBeforeUpdate: true')
}
......@@ -6,7 +6,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
## [Unreleased]
### Added
- documentation for `__skipSelectBeforeUpdate` `CustomRepository.misc` flag (added in UB@5.18.9)
### Changed
### Deprecated
......
......@@ -19,7 +19,7 @@ for (let i = 0; i < 100; i++) {
const KNOWN_MISC_TAGS = new Set(['__mip_ondate', '__mip_recordhistory', '__mip_recordhistory_all',
'__mip_disablecache', '__skipOptimisticLock', '__allowSelectSafeDeleted', '__skipSelectAfterUpdate',
'__skipSelectAfterInsert', '__skipRls', '__skipAclRls', 'lockType'])
'__skipSelectAfterInsert', '__skipSelectBeforeUpdate', '__skipRls', '__skipAclRls', 'lockType'])
/**
* Ancestor for Browser/NodeJS ClientRepository and server side ServerRepository.
......@@ -804,6 +804,9 @@ inst.run('select', repo.ubql())
* @param {Boolean} [flags.__allowSelectSafeDeleted=false] Include softly deleted rows to the result
* @param {Boolean} [flags.__skipSelectAfterUpdate=false] **Server-side only.**
* @param {Boolean} [flags.__skipSelectAfterInsert=false] **Server-side only.**
* @param {Boolean} [flags.__skipSelectBeforeUpdate=false] **Server-side only.** if added then `mStorage` mixin don't execute `select` before execution of `update`.
* As a **UNSAFE** side effect `update` won't check record is accessible to user.
* **UNSAFE** If `Audit` mixin is implemented for entity empty OldValue in inserted into `uba_auditTrail` in case this flag is enabled, so better to think twice before skip select before update
* @param {Boolean} [flags.__skipRls=false] **Server-side only.**
* @param {Boolean} [flags.__skipAclRls=false] **Server-side only.**
* @param {string} [flags.lockType] For entities with `softLock` mixin retrieve/set a lock during method execution.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment