-
Notifications
You must be signed in to change notification settings - Fork 3
Sync 0.11.x #99
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
Sync 0.11.x #99
Conversation
WalkthroughThe changes update the CSV migration source to handle internal attributes more explicitly, introducing stricter validation and clearer error messages for CSV import/export. The cache logic is also corrected to properly verify resource existence before removal, fixing the key used to check the cache. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant CSVSource
participant Row
User->>CSVSource: Import CSV
CSVSource->>CSVSource: Validate headers (exclude allowed internals)
CSVSource->>CSVSource: Parse rows
CSVSource->>Row: Construct Row (with $permissions and other attributes)
Row-->>CSVSource: Row object created
CSVSource-->>User: Import result or error
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~15 minutes Possibly related PRs
Suggested reviewers
Poem
Note ⚡️ Unit Test Generation is now available in beta!Learn more here, or try it out under "Finishing Touches" below. ✨ Finishing Touches
🧪 Generate unit tests✅ Unit Test PR creation complete.
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. 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: 0
🧹 Nitpick comments (2)
src/Migration/Sources/CSV.php (2)
217-222: Simplify the validation logic for consistencyThe condition
$key !== '$permissions'on line 217 is redundant since$permissionsis already included inALLOWED_INTERNALS. This creates confusion about the intent.Apply this diff to simplify the logic:
-if (!isset($type) && $key !== '$permissions') { +if (!isset($type)) { if (isset(self::ALLOWED_INTERNALS[$key])) { continue; } throw new \Exception('Unexpected attribute in CSV: '.$key); }
376-379: Use ALLOWED_INTERNALS constant for consistencyThe method hardcodes the internal columns list while the
ALLOWED_INTERNALSconstant already exists for this purpose.Apply this diff to maintain consistency:
-$internalColumns = ['$id', '$permissions', '$createdAt', '$updatedAt']; +$internalColumns = array_keys(self::ALLOWED_INTERNALS); $expectedColumns = \array_keys($columnTypes); $extraColumns = \array_diff($headers, $expectedColumns, $internalColumns); $missingColumns = \array_diff($expectedColumns, $headers);
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/Migration/Cache.php(2 hunks)src/Migration/Sources/CSV.php(8 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: ItzNotABug
PR: utopia-php/migration#80
File: src/Migration/Sources/Supabase.php:300-308
Timestamp: 2025-06-28T09:47:58.757Z
Learning: In the utopia-php/migration codebase, during the terminology swap from Collection/Attribute/Document to Table/Column/Row, the user ItzNotABug prefers to keep the existing query logic unchanged even if it becomes semantically incorrect with the new naming. The focus is purely on resource type renaming, not on fixing logical issues that become apparent after the terminology change.
Learnt from: ItzNotABug
PR: utopia-php/migration#80
File: src/Migration/Sources/Appwrite.php:843-851
Timestamp: 2025-06-28T09:47:08.333Z
Learning: In the utopia-php/migration codebase, during the terminology swap from Collection/Attribute/Document to Table/Column/Row, the class constructors and method parameters use the new terminology (like "relatedTable"), but the underlying data structures and API responses still use the legacy keys (like "relatedCollection"). This is an intentional design pattern to allow gradual migration while maintaining compatibility with existing data sources.
src/Migration/Sources/CSV.php (3)
Learnt from: ItzNotABug
PR: #80
File: src/Migration/Sources/Appwrite.php:843-851
Timestamp: 2025-06-28T09:47:08.333Z
Learning: In the utopia-php/migration codebase, during the terminology swap from Collection/Attribute/Document to Table/Column/Row, the class constructors and method parameters use the new terminology (like "relatedTable"), but the underlying data structures and API responses still use the legacy keys (like "relatedCollection"). This is an intentional design pattern to allow gradual migration while maintaining compatibility with existing data sources.
Learnt from: ItzNotABug
PR: #80
File: src/Migration/Sources/Supabase.php:300-308
Timestamp: 2025-06-28T09:47:58.757Z
Learning: In the utopia-php/migration codebase, during the terminology swap from Collection/Attribute/Document to Table/Column/Row, the user ItzNotABug prefers to keep the existing query logic unchanged even if it becomes semantically incorrect with the new naming. The focus is purely on resource type renaming, not on fixing logical issues that become apparent after the terminology change.
Learnt from: ItzNotABug
PR: #80
File: src/Migration/Resources/Database/Row.php:60-60
Timestamp: 2025-06-28T09:45:36.026Z
Learning: In the utopia-php/migration codebase, the fromArray method is not used on Row objects, so mismatches between jsonSerialize() output keys and fromArray() input expectations for Row class are not problematic.
🔇 Additional comments (1)
src/Migration/Cache.php (1)
175-177: Critical fix: Corrected cache existence checkThe cache check was previously using
in_array($resource, $this->cache[$resource->getName()])which would always fail since the cache stores resources by their cache keys, not as direct array values. The fix properly checks for resource existence using the resource type as the key.
|
@coderabbitai generate unit tests |
|
Note Unit test generation is an Early Access feature. Expect some limitations and changes as we gather feedback and continue to improve it. Generating unit tests... This may take up to 20 minutes. |
|
✅ UTG Post-Process Complete No new issues were detected in the generated code and all check runs have completed. The unit test generation process has completed successfully. |
|
Unit Test Generation process completed. You can view the generated tests in this PR: View PR |
✅ Actions performedUnit Test Generation started... |
|
✅ UTG Post-Process Complete No new issues were detected in the generated code and all check runs have completed. The unit test generation process has completed successfully. |
|
Creating a PR to put the unit tests in... The changes have been created in this pull request: View PR |
Summary by CodeRabbit
Bug Fixes
New Features
Style