-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
fix: Avoid deleting meta on LTAR description update - WIP #9684
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Avoid deleting meta on LTAR description update - WIP #9684
Conversation
📝 WalkthroughWalkthroughThe pull request introduces significant updates to the Changes
Assessment against linked issues
Possibly related PRs
Suggested labels
Suggested reviewers
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 4
🧹 Outside diff range and nitpick comments (1)
packages/nocodb/src/version-upgrader/upgraders/0227002_ncBrokenLinkRecovery.ts (1)
231-231: Address theTODOcomment forONE_TO_ONErelation typeThere is a
TODOcomment indicating that additional implementation is needed for handlingONE_TO_ONErelation types. Ensuring this case is properly implemented is crucial for recovering broken links accurately.Would you like assistance in completing the implementation for
ONE_TO_ONErelations? I can help draft the necessary code or logic to handle this case effectively.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (4)
- packages/nocodb/src/models/Column.ts (3 hunks)
- packages/nocodb/src/providers/init-meta-service.provider.ts (1 hunks)
- packages/nocodb/src/version-upgrader/NcUpgrader.ts (2 hunks)
- packages/nocodb/src/version-upgrader/upgraders/0227002_ncBrokenLinkRecovery.ts (1 hunks)
🧰 Additional context used
🪛 Biome
packages/nocodb/src/models/Column.ts
[error] 1366-1366: Using this in a static context can be confusing.
this refers to the class.
Unsafe fix: Use the class name instead.(lint/complexity/noThisInStatic)
packages/nocodb/src/version-upgrader/upgraders/0227002_ncBrokenLinkRecovery.ts
[error] 232-234: Other switch clauses can erroneously access this declaration.
Wrap the declaration in a block to restrict its access to the switch clause.The declaration is defined in this switch clause:
Unsafe fix: Wrap the declaration in a block.
(lint/correctness/noSwitchDeclarations)
🔇 Additional comments (8)
packages/nocodb/src/providers/init-meta-service.provider.ts (2)
34-34: Version update approved, but implementation for LTAR fix is missing.The version update from '0225002' to '0257002' is appropriate for a new release that includes bug fixes. However, I don't see any implementation in this file or the provided changes that directly addresses the LTAR description update issue mentioned in the PR objectives.
To ensure the LTAR description update fix is implemented elsewhere, please run the following script:
#!/bin/bash # Description: Search for changes related to LTAR description update # Test: Look for changes in files related to LTAR or column updates rg --type typescript -i "ltar|linkstoanotherrecord|column.*update" -g '!*test*'If the script doesn't return any relevant results, it might indicate that the implementation for the LTAR fix is missing from this PR.
Line range hint
1-158: PR implementation appears incomplete based on the provided changes.While the version update is appropriate, the changes in this file don't directly address the LTAR description update issue mentioned in the PR objectives. The PR seems incomplete as it lacks the implementation for fixing the bug related to updating the LTAR description without deleting metadata.
Please ensure that the necessary changes to fix the LTAR description update issue are included in this PR, possibly in other files that weren't provided for this review.
To confirm if other relevant changes exist in the PR, run the following script:
This will help identify if there are other files in the PR that might contain the implementation for the LTAR description update fix.
packages/nocodb/src/version-upgrader/NcUpgrader.ts (2)
15-15: LGTM: New upgrader import added correctly.The import statement for
ncBrokenLinkRecoveryis correctly placed and follows the existing pattern for importing upgraders. This aligns with the PR objective of addressing issues related to LTAR (Links to Another Resource) columns.
15-15: Overall impact: New upgrader added for broken link recovery.The changes successfully integrate a new upgrader (
ncBrokenLinkRecovery) into the existing upgrade process. This addition aligns with the PR objective of addressing issues related to LTAR (Links to Another Resource) columns.The implementation follows established patterns, minimizing the risk of introducing new issues. However, given the critical nature of the upgrade process, I recommend:
- Thorough testing of the new upgrader in isolation.
- End-to-end testing of the entire upgrade process to ensure it runs smoothly with the new addition.
- Verification that the upgrader successfully recovers broken links as intended.
To ensure the new upgrader functions correctly within the upgrade process, please run the following test:
#!/bin/bash # Simulate the upgrade process and verify the new upgrader is called # Mock the upgrade context and other necessary objects # This is a simplified example and may need to be adjusted based on your testing framework mock_context() { echo "Mocking upgrade context..." } # Mock the ncBrokenLinkRecovery function mock_ncBrokenLinkRecovery() { echo "Mock ncBrokenLinkRecovery called" } # Run the upgrade process run_upgrade() { echo "Running upgrade process..." # Simulate calling NcUpgrader.upgrade() # This is where you'd actually call the upgrade method in your test environment } # Main test script mock_context mock_ncBrokenLinkRecovery run_upgrade echo "Please verify that 'Mock ncBrokenLinkRecovery called' appears in the output, indicating the new upgrader was successfully integrated into the upgrade process."Also applies to: 155-155
packages/nocodb/src/version-upgrader/upgraders/0227002_ncBrokenLinkRecovery.ts (2)
277-285: Consider handling the deletion of unrecoverable link columns carefullyWhen deleting link columns that are not recoverable, it's important to ensure that this action won't negatively impact data integrity or leave orphaned data.
Please verify that deleting the link column is safe in this context and won't affect related data. If there are dependent records or constraints, you might need to handle them explicitly.
207-285:⚠️ Potential issueVerify the logic in the
if-elsestatement for correct error handlingThe current
if-elselogic seems inverted:
- When
columnInCurrTableis not found (!columnInCurrTable), the code attempts to generate metadata and insert intocolOptions.- When
columnInCurrTableis found, it logs an error and deletes the link column.Intuitively, if
columnInCurrTableis not found, we might not have enough information to proceed, and perhaps we should log an error or handle the missing data accordingly.Please review the logic to ensure that it's handling the conditions as intended. If necessary, adjust the
if-elseblocks to correctly address the presence or absence ofcolumnInCurrTable.🧰 Tools
🪛 Biome
[error] 232-234: Other switch clauses can erroneously access this declaration.
Wrap the declaration in a block to restrict its access to the switch clause.The declaration is defined in this switch clause:
Unsafe fix: Wrap the declaration in a block.
(lint/correctness/noSwitchDeclarations)
packages/nocodb/src/models/Column.ts (2)
1115-1115: Initialization ofinsertColOptThe variable
insertColOptis initialized totrueto control the insertion of column options based on the presence of required fields. This initialization is appropriate and sets up the correct default behavior.
1152-1163: Conditional check for required fields before deleting column optionsThe added conditional check ensures that column options are only deleted if all required fields are present. This prevents the deletion of existing column options when not all required fields are provided, preserving metadata integrity during updates.
packages/nocodb/src/version-upgrader/upgraders/0227002_ncBrokenLinkRecovery.ts
Outdated
Show resolved
Hide resolved
packages/nocodb/src/version-upgrader/upgraders/0227002_ncBrokenLinkRecovery.ts
Outdated
Show resolved
Hide resolved
|
Uffizzi Preview |
e998c92 to
ab00097
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Outside diff range and nitpick comments (1)
packages/nocodb/src/models/Column.ts (1)
Line range hint
1115-1366: Overall changes in theupdatemethodThe changes in the
updatemethod improve the handling of column options for different UI types. The introduction of theinsertColOptflag and the conditional checks for required fields enhance the robustness of the update process.However, there are a few suggestions for further improvement:
- Consider adding comments to explain the purpose of the
insertColOptflag and its usage.- The error handling for the case when required fields are missing could be improved. Currently, it silently skips the insertion of column options. Consider logging a warning or throwing an error in such cases.
- The code structure could be improved by extracting the logic for each UI type into separate methods to enhance readability and maintainability.
Consider refactoring the
updatemethod to improve its structure and error handling. Here's a high-level suggestion:static async update(context: NcContext, colId: string, column: Partial<Column> & Partial<Pick<ColumnReqType, 'column_order'>>, ncMeta = Noco.ncMeta, skipFormulaInvalidate = false) { const oldCol = await Column.get(context, { colId }, ncMeta); let insertColOpt = true; // Handle column option deletion and checks insertColOpt = await this.handleColumnOptionDeletion(context, oldCol, column, colId, ncMeta); // Update column metadata await this.updateColumnMetadata(context, colId, column, ncMeta); // Insert new column options if necessary if (insertColOpt) { await Column.insertColOption(context, column, colId, ncMeta); } // Handle cache updates and formula invalidation await this.handleCacheAndFormulaInvalidation(context, oldCol, column, colId, ncMeta, skipFormulaInvalidate); return await Column.get(context, { colId }, ncMeta); } private static async handleColumnOptionDeletion(context: NcContext, oldCol: Column, column: Partial<Column>, colId: string, ncMeta): Promise<boolean> { // Implement the logic for deleting old column options and checking required fields // Return whether new column options should be inserted } private static async updateColumnMetadata(context: NcContext, colId: string, column: Partial<Column>, ncMeta) { // Implement the logic for updating column metadata } private static async handleCacheAndFormulaInvalidation(context: NcContext, oldCol: Column, column: Partial<Column>, colId: string, ncMeta, skipFormulaInvalidate: boolean) { // Implement the logic for cache updates and formula invalidation }This refactoring suggestion aims to improve the structure of the
updatemethod by breaking it down into smaller, more focused methods. It also provides an opportunity to improve error handling and add more detailed comments.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (4)
- packages/nocodb/src/models/Column.ts (3 hunks)
- packages/nocodb/src/providers/init-meta-service.provider.ts (1 hunks)
- packages/nocodb/src/version-upgrader/NcUpgrader.ts (2 hunks)
- packages/nocodb/src/version-upgrader/upgraders/0227002_ncBrokenLinkRecovery.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
- packages/nocodb/src/providers/init-meta-service.provider.ts
- packages/nocodb/src/version-upgrader/NcUpgrader.ts
- packages/nocodb/src/version-upgrader/upgraders/0227002_ncBrokenLinkRecovery.ts
🧰 Additional context used
🪛 Biome
packages/nocodb/src/models/Column.ts
[error] 1366-1366: Using this in a static context can be confusing.
this refers to the class.
Unsafe fix: Use the class name instead.(lint/complexity/noThisInStatic)
🔇 Additional comments (2)
packages/nocodb/src/models/Column.ts (2)
1115-1115: New variableinsertColOptintroducedA new boolean variable
insertColOpthas been introduced and initialized totrue. This variable is used to control whether new column options should be inserted.
1150-1164: Conditional insertion of column options for Links and LinkToAnotherRecordThe code now checks for the presence of required fields before deleting and reinserting column options for Links and LinkToAnotherRecord types. This change improves data integrity by ensuring all necessary information is available before modifying the database.
ab00097 to
827dc57
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 5
🧹 Outside diff range and nitpick comments (1)
packages/nocodb/src/version-upgrader/upgraders/0227002_ncBrokenLinkRecovery.ts (1)
23-23: Use descriptive label for console.timeThe current timing label is not descriptive of what's being measured.
- console.time('==================================') + console.time('ncBrokenLinkRecovery-upgrade-duration')
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (4)
- packages/nocodb/src/models/Column.ts (3 hunks)
- packages/nocodb/src/providers/init-meta-service.provider.ts (1 hunks)
- packages/nocodb/src/version-upgrader/NcUpgrader.ts (2 hunks)
- packages/nocodb/src/version-upgrader/upgraders/0227002_ncBrokenLinkRecovery.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
- packages/nocodb/src/providers/init-meta-service.provider.ts
- packages/nocodb/src/version-upgrader/NcUpgrader.ts
🧰 Additional context used
🪛 Biome
packages/nocodb/src/models/Column.ts
[error] 1366-1366: Using this in a static context can be confusing.
this refers to the class.
Unsafe fix: Use the class name instead.(lint/complexity/noThisInStatic)
🔇 Additional comments (2)
packages/nocodb/src/models/Column.ts (2)
1115-1115: LGTM: Good addition of control flagThe introduction of
insertColOptprovides better control over column option insertion during updates.
1152-1163: LGTM: Effectively prevents metadata loss during LTAR updatesThis change successfully addresses the PR objective by preserving LTAR metadata when only the description is being updated. The code checks for all required fields before proceeding with metadata deletion, preventing the table from becoming inaccessible.
packages/nocodb/src/version-upgrader/upgraders/0227002_ncBrokenLinkRecovery.ts
Outdated
Show resolved
Hide resolved
packages/nocodb/src/version-upgrader/upgraders/0227002_ncBrokenLinkRecovery.ts
Show resolved
Hide resolved
packages/nocodb/src/version-upgrader/upgraders/0227002_ncBrokenLinkRecovery.ts
Show resolved
Hide resolved
packages/nocodb/src/version-upgrader/upgraders/0227002_ncBrokenLinkRecovery.ts
Show resolved
Hide resolved
12ebda4 to
e5abd85
Compare
e5abd85 to
3ce52ed
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (3)
packages/nocodb/src/models/Column.ts(3 hunks)packages/nocodb/src/version-upgrader/NcUpgrader.ts(2 hunks)packages/nocodb/src/version-upgrader/upgraders/0227002_ncBrokenLinkRecovery.ts(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
- packages/nocodb/src/version-upgrader/NcUpgrader.ts
- packages/nocodb/src/version-upgrader/upgraders/0227002_ncBrokenLinkRecovery.ts
🧰 Additional context used
🪛 Biome
packages/nocodb/src/models/Column.ts
[error] 1366-1366: Using this in a static context can be confusing.
this refers to the class.
Unsafe fix: Use the class name instead.
(lint/complexity/noThisInStatic)
Change Summary
Change type
Test/ Verification
Provide summary of changes.
Additional information / screenshots (optional)
Anything for maintainers to be made aware of