fix(core-flows): complete cart improvements (#12646)
* fix(core-flows): use cartId as transactionId and acquire lock to complete cart * fix cart update compensation
This commit is contained in:
committed by
GitHub
parent
820965e21a
commit
490bd7647f
+8
-5
@@ -40,7 +40,7 @@ describe("getSelectsAndRelationsFromObjectArray", function () {
|
||||
},
|
||||
],
|
||||
output: {
|
||||
selects: [
|
||||
selects: expect.arrayContaining([
|
||||
"attr_string",
|
||||
"attr_boolean",
|
||||
"attr_null",
|
||||
@@ -55,16 +55,19 @@ describe("getSelectsAndRelationsFromObjectArray", function () {
|
||||
"attr_array.attr_object.attr_boolean",
|
||||
"attr_array.attr_object.attr_null",
|
||||
"attr_array.attr_object.attr_undefined",
|
||||
],
|
||||
"required_attr",
|
||||
]),
|
||||
relations: ["attr_object", "attr_array", "attr_array.attr_object"],
|
||||
},
|
||||
},
|
||||
]
|
||||
|
||||
expectations.forEach((expectation) => {
|
||||
expect(getSelectsAndRelationsFromObjectArray(expectation.input)).toEqual(
|
||||
expectation.output
|
||||
)
|
||||
expect(
|
||||
getSelectsAndRelationsFromObjectArray(expectation.input, {
|
||||
requiredFields: ["required_attr"],
|
||||
})
|
||||
).toEqual(expectation.output)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@@ -5,8 +5,9 @@ const KEYS_THAT_ARE_NOT_RELATIONS = ["metadata"]
|
||||
|
||||
export function getSelectsAndRelationsFromObjectArray(
|
||||
dataArray: object[],
|
||||
options: { objectFields: string[] } = {
|
||||
objectFields: [],
|
||||
options?: {
|
||||
objectFields?: string[]
|
||||
requiredFields?: string[]
|
||||
},
|
||||
prefix?: string
|
||||
): {
|
||||
@@ -15,10 +16,11 @@ export function getSelectsAndRelationsFromObjectArray(
|
||||
} {
|
||||
const selects: string[] = []
|
||||
const relations: string[] = []
|
||||
const { objectFields, requiredFields } = options ?? {}
|
||||
|
||||
for (const data of dataArray) {
|
||||
for (const [key, value] of Object.entries(data)) {
|
||||
if (isObject(value) && !options.objectFields.includes(key)) {
|
||||
if (isObject(value) && !objectFields?.includes(key)) {
|
||||
const res = getSelectsAndRelationsFromObjectArray(
|
||||
[value],
|
||||
options,
|
||||
@@ -48,7 +50,10 @@ export function getSelectsAndRelationsFromObjectArray(
|
||||
}
|
||||
}
|
||||
|
||||
const uniqueSelects: string[] = deduplicate(selects)
|
||||
const uniqueSelects: string[] = deduplicate([
|
||||
...selects,
|
||||
...(requiredFields ?? []),
|
||||
])
|
||||
const uniqueRelations: string[] = deduplicate(relations)
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user