( conditions: ColumnLevelCondition[] )
| 604 | }; |
| 605 | |
| 606 | const mergeColumnLevelConditions = ( |
| 607 | conditions: ColumnLevelCondition[] |
| 608 | ): ColumnLevelCondition[] => { |
| 609 | const groupedConditions: Record<string, string[]> = {}; |
| 610 | |
| 611 | for (const condition of conditions) { |
| 612 | const { database, schema, table, column } = condition; |
| 613 | const key = `${database}:${schema}:${table}`; |
| 614 | |
| 615 | if (groupedConditions[key]) { |
| 616 | groupedConditions[key] = [...groupedConditions[key], ...column]; |
| 617 | } else { |
| 618 | groupedConditions[key] = [...column]; |
| 619 | } |
| 620 | } |
| 621 | |
| 622 | const mergedConditions: ColumnLevelCondition[] = []; |
| 623 | |
| 624 | for (const key of Object.keys(groupedConditions)) { |
| 625 | const [database, schema, table] = key.split(":"); |
| 626 | const condition: ColumnLevelCondition = { |
| 627 | database, |
| 628 | schema, |
| 629 | table, |
| 630 | column: groupedConditions[key], |
| 631 | }; |
| 632 | mergedConditions.push(condition); |
| 633 | } |
| 634 | |
| 635 | return mergedConditions; |
| 636 | }; |
no test coverage detected