mirror of
https://github.com/frappe/books.git
synced 2025-02-02 03:58:26 +00:00
incr: use parent and fieldname for SVs
(to prevent dupes)
This commit is contained in:
parent
bb7ec1a6a8
commit
bf2d0192ef
@ -786,18 +786,19 @@ export default class DatabaseCore extends DatabaseBase {
|
||||
fieldname: string,
|
||||
value: RawValue
|
||||
) {
|
||||
const updateKey = {
|
||||
parent: singleSchemaName,
|
||||
fieldname,
|
||||
};
|
||||
|
||||
const names: { name: string }[] = await this.knex!('SingleValue')
|
||||
.select('name')
|
||||
.where({
|
||||
parent: singleSchemaName,
|
||||
fieldname,
|
||||
});
|
||||
const name = names?.[0]?.name as string | undefined;
|
||||
.where(updateKey);
|
||||
|
||||
if (name === undefined) {
|
||||
if (!names?.length) {
|
||||
this.#insertSingleValue(singleSchemaName, fieldname, value);
|
||||
} else {
|
||||
return await this.knex!('SingleValue').where({ name }).update({
|
||||
return await this.knex!('SingleValue').where(updateKey).update({
|
||||
value,
|
||||
modifiedBy: SYSTEM,
|
||||
modified: new Date().toISOString(),
|
||||
|
Loading…
x
Reference in New Issue
Block a user