You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This PR depends on #2108. Once #2108 is merged, this PR will be ready for review and the WIP prefix will be removed.
Issue
resolve: Implement support for REMOVE COLUMN operations in the database schema operation system
Why is this change needed?
This change adds support for the remove operation on columns, allowing users to generate ALTER TABLE DROP COLUMN DDL statements through the operation system.
What would you like reviewers to focus on?
Schema definition for RemoveColumnOperation in column.ts
DDL generation logic in generateRemoveColumnStatement function
Integration with the operation deparser
Test coverage for the new functionality
Testing Verification
All existing tests continue to pass (233 passed | 1 skipped)
New comprehensive tests added for remove column operations
Verified DDL generation produces correct ALTER TABLE {tableName} DROP COLUMN {columnName}; statements
Ran quality checks: pnpm fmt, pnpm lint, and pnpm test all pass
• Add support for REMOVE COLUMN operations in database schema system
• Implement DDL generation for ALTER TABLE DROP COLUMN statements
• Add comprehensive test coverage for column removal functionality
• Integrate remove column operation with existing deparser system
• Import RemoveColumnOperation type and type guard function • Add generateRemoveColumnFromOperation function for DDL generation • Integrate remove column operation handling in main deparser logic
• Define RemoveColumnOperation schema with validation • Add isRemoveColumnOperation type guard function • Export remove column operation in columnOperations array
- Add RemoveColumnOperation schema and type guard to column.ts
- Implement generateRemoveColumnStatement utility function
- Support DROP COLUMN DDL generation in operationDeparser
- Add comprehensive tests for remove column operations
- Update existing operations to handle column removal functionality
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <[email protected]>
Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.
This PR includes no changesets
When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types
Tasks are run on every commit but only new migration files are pushed.
Close and reopen this PR if you want to apply changes from existing seed or migration files.
Here are some key observations to aid the review process:
⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
🧪 PR contains tests
🔒 Security concerns
SQL injection: The generateRemoveColumnStatement function in utils.ts directly concatenates tableName and columnName into SQL without proper escaping or validation. If these values originate from user input, this could allow SQL injection attacks. Consider using parameterized queries or proper SQL identifier escaping.
The generateRemoveColumnStatement function directly interpolates tableName and columnName into the SQL string without proper escaping or validation, which could lead to SQL injection vulnerabilities if these values come from user input.
exportfunctiongenerateRemoveColumnStatement(tableName: string,columnName: string,): string{return`ALTER TABLE ${tableName} DROP COLUMN ${columnName};`}
The generateRemoveColumnFromOperation function throws an error when pathInfo is null, but this error is not caught or handled in the main deparser function, potentially causing unhandled exceptions.
The function should validate input parameters to prevent SQL injection or malformed statements. Add basic validation to ensure tableName and columnName are not empty or contain dangerous characters.
export function generateRemoveColumnStatement(
tableName: string,
columnName: string,
): string {
+ if (!tableName?.trim() || !columnName?.trim()) {+ throw new Error('Table name and column name must be non-empty strings')+ }
return `ALTER TABLE ${tableName} DROP COLUMN ${columnName};`
}
Apply / Chat
Suggestion importance[1-10]: 9
__
Why: The suggestion correctly identifies a potential security vulnerability (SQL injection) in the new generateRemoveColumnStatement function. Directly using input parameters to construct SQL queries without validation is unsafe. This is a critical security improvement.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR depends on #2108. Once #2108 is merged, this PR will be ready for review and the WIP prefix will be removed.
Issue
Why is this change needed?
This change adds support for the
remove
operation on columns, allowing users to generateALTER TABLE DROP COLUMN
DDL statements through the operation system.What would you like reviewers to focus on?
column.ts
generateRemoveColumnStatement
functionTesting Verification
ALTER TABLE {tableName} DROP COLUMN {columnName};
statementspnpm fmt
,pnpm lint
, andpnpm test
all passWhat was done
🤖 Generated by PR Agent at df53d71
• Add support for REMOVE COLUMN operations in database schema system
• Implement DDL generation for ALTER TABLE DROP COLUMN statements
• Add comprehensive test coverage for column removal functionality
• Integrate remove column operation with existing deparser system
Detailed Changes
operationDeparser.test.ts
Add tests for remove column operation
frontend/packages/db-structure/src/deparser/postgresql/operationDeparser.test.ts
• Add test case for DROP COLUMN statement generation from remove
operation
• Verify correct DDL output for column removal operations
operationDeparser.ts
Integrate remove column operation in deparser
frontend/packages/db-structure/src/deparser/postgresql/operationDeparser.ts
• Import RemoveColumnOperation type and type guard function
• Add
generateRemoveColumnFromOperation function for DDL generation
•
Integrate remove column operation handling in main deparser logic
utils.ts
Add utility for DROP COLUMN statement generation
frontend/packages/db-structure/src/deparser/postgresql/utils.ts
• Add generateRemoveColumnStatement utility function
• Generate ALTER
TABLE DROP COLUMN DDL statements
column.ts
Define remove column operation schema
frontend/packages/db-structure/src/operation/schema/column.ts
• Define RemoveColumnOperation schema with validation
• Add
isRemoveColumnOperation type guard function
• Export remove column
operation in columnOperations array
Additional Notes
This implementation follows the established operation support pattern and maintains consistency with existing column operations.
🤖 Generated with Claude Code