Skip to content

Conversation

@ymc9
Copy link
Member

@ymc9 ymc9 commented Feb 2, 2026

Summary by CodeRabbit

  • New Features
    • String fields now support TinyText, MediumText, and LongText modifiers
    • Integer fields gain unsigned variants and additional types: TinyInt (with length), UnsignedTinyInt, UnsignedSmallInt, UnsignedMediumInt, UnsignedInt, MediumInt, Year, and UnsignedBigInt
    • Floating-point fields include Float and Double
    • DateTime accepts an optional precision parameter
    • Bytes fields support LongBlob, TinyBlob, Blob, MediumBlob, Binary(n) and VarBinary(n)

Copilot AI review requested due to automatic review settings February 2, 2026 14:45
@coderabbitai
Copy link

coderabbitai bot commented Feb 2, 2026

Warning

Rate limit exceeded

@ymc9 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 18 minutes and 44 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📝 Walkthrough

Walkthrough

This PR adds numerous new database field attribute modifiers and parameterized forms to the standard library model, introducing additional string, integer (including unsigned and parameterized tiny/medium), floating, blob/binary, and DateTime variants in packages/language/res/stdlib.zmodel.

Changes

Cohort / File(s) Summary
Stdlib DB Attribute Additions
packages/language/res/stdlib.zmodel
Added many new @db.*() attributes: string types (TinyText, MediumText, LongText); unsigned and sized integers (UnsignedInt, UnsignedSmallInt, UnsignedMediumInt, UnsignedTinyInt, UnsignedBigInt, MediumInt, TinyInt(_ length: Int?), UnsignedTinyInt(_ length: Int?), Year); extended BigInt with UnsignedBigInt; floating types (Float, Double); date/time parameterized (DateTime(_ x: Int?)); and bytes/blob/binary variants (LongBlob, TinyBlob, Blob, MediumBlob, Binary(_ n: Int?), VarBinary(_ n: Int?)). Changes are additive declarations only.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐇 I hopped through schemas, added types anew,
TinyText and blobs, a colorful view.
Unsigned numbers, floats that gleam,
DateTime with precision — a rabbit's dream.
🍃✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix(mysql): add native type mapping attributes' directly and clearly describes the main change: adding native type mapping attributes for MySQL in the stdlib.zmodel file.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/mysql-native-mapping

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@claude
Copy link

claude bot commented Feb 2, 2026

Claude finished @ymc9's task —— View job


Pull Request Review

I've analyzed this PR that adds MySQL native type mapping attributes to the ZModel standard library. Here's my comprehensive review:

Review Checklist:

  • Read and analyze the changed file
  • Check code quality and best practices
  • Look for potential bugs or issues
  • Evaluate performance considerations
  • Review security concerns
  • Assess test coverage

Code Quality & Best Practices

Excellent work overall! The changes follow established patterns in the codebase:

  • Consistent formatting: All new attributes follow the same format as existing ones
  • Proper targeting: Uses @@@targetField([FieldType]) correctly to restrict attributes to appropriate field types
  • Prisma compatibility: All attributes are properly marked with @@@prisma
  • Good organization: Attributes are logically grouped with existing similar types

Strong points:

  • Clean, consistent additions without modifying existing code
  • Proper parameter handling (e.g., _ length: Int? for TinyInt/UnsignedTinyInt)
  • Logical placement within existing type modifier sections

🔍 Specific Changes Analysis

The PR adds 15 new MySQL-specific database type attributes:

String types: TinyText, MediumText, LongText - packages/language/res/stdlib.zmodel:429-431
Integer types: UnsignedInt, UnsignedSmallInt, MediumInt, UnsignedMediumInt, TinyInt, UnsignedTinyInt, Year - packages/language/res/stdlib.zmodel:443-451
BigInt types: UnsignedBigInt - packages/language/res/stdlib.zmodel:454
Float types: Float, Double - packages/language/res/stdlib.zmodel:461-462
DateTime fix: Date and DateTime now accept optional precision parameter - packages/language/res/stdlib.zmodel:468,471
Bytes types: LongBlob, Binary, VarBinary, TinyBlob, Blob, MediumBlob - packages/language/res/stdlib.zmodel:482-487

⚠️ Potential Issues

  1. Missing Documentation: The PR lacks a description explaining the purpose and scope of these additions.

  2. Test Coverage Gap: No tests verify these new attributes work correctly. Consider adding tests like:

    // Test that @db.TinyText() is valid on StringField
    // Test that @db.UnsignedInt() is valid on IntField 
    // Test error handling for incorrect field type targeting
  3. Version Compatibility: While these attributes are MySQL-specific, there's no indication of MySQL version requirements (e.g., some types may require MySQL 5.7+ or 8.0+).

🚀 Performance Considerations

Positive impact: These native type mappings can improve performance by:

  • Using more precise data types (e.g., TinyInt vs generic Int)
  • Better storage efficiency (e.g., TinyText vs Text for short strings)
  • Optimal index performance with appropriate numeric types

No performance risks identified in the implementation itself.

🔒 Security Considerations

No security concerns identified. The changes:

  • Don't introduce user input validation
  • Don't affect runtime behavior directly
  • Are limited to schema definition attributes
  • Follow established security patterns in the codebase

📊 Test Coverage Assessment

Needs improvement: The language package has comprehensive attribute validation tests (packages/language/test/attribute-application.test.ts), but these new MySQL attributes aren't tested.

Recommendations:

  1. Add basic validation tests ensuring the attributes are accepted on correct field types
  2. Add negative tests ensuring they're rejected on incorrect field types
  3. Consider integration tests with actual MySQL schema generation

🎯 Overall Assessment

This is a solid, low-risk PR that enhances ZenStack's MySQL support. The implementation is clean, consistent, and follows established patterns. The main areas for improvement are documentation and test coverage.

Recommendation: ✅ Approve with suggestions

The code quality is high and the changes are beneficial. Consider addressing test coverage in a follow-up PR if not in this one.


Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds MySQL-specific native type mapping attributes to the ZModel stdlib to improve compatibility with MySQL database types. These attributes are used to specify the exact MySQL native types when mapping ZModel fields to database columns.

Changes:

  • Added MySQL text type attributes: TinyText, MediumText, and LongText for String fields
  • Added MySQL integer type attributes: UnsignedInt, UnsignedSmallInt, MediumInt, UnsignedMediumInt, TinyInt, UnsignedTinyInt, and Year
  • Added MySQL BigInt variant: UnsignedBigInt
  • Added MySQL floating-point type attributes: Float and Double
  • Added MySQL DateTime attribute and modified Date to accept an optional precision parameter
  • Added MySQL binary data type attributes: LongBlob, Binary, VarBinary, TinyBlob, Blob, and MediumBlob

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

@coderabbitai coderabbitai bot left a 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

🤖 Fix all issues with AI agents
In `@packages/language/res/stdlib.zmodel`:
- Around line 447-471: The `@db.Date` attribute is incorrectly defined with a
precision parameter; update the attribute declaration for `@db.Date` so it has no
parameters (change attribute `@db.Date`(_ x: Int?) to attribute `@db.Date`() ) while
keeping its @@@targetField([DateTimeField]) @@@prisma metadata unchanged; ensure
any references expecting fractional-second precision use `@db.DateTime`(x),
`@db.Timestamp`(x), or `@db.Time`(x) instead.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@claude
Copy link

claude bot commented Feb 3, 2026

Claude finished @ymc9's task —— View job


Pull Request Review

I've analyzed this PR that adds MySQL native type mapping attributes to the ZModel standard library. Here's my comprehensive review:

Review Checklist:

  • Read and analyze the changed file
  • Check code quality and best practices
  • Look for potential bugs or issues
  • Evaluate performance considerations
  • Review security concerns
  • Assess test coverage

Code Quality & Best Practices

Excellent work overall! The changes follow established patterns in the codebase:

  • Consistent formatting: All new attributes follow the same format as existing ones
  • Proper targeting: Uses @@@targetField([FieldType]) correctly to restrict attributes to appropriate field types
  • Prisma compatibility: All attributes are properly marked with @@@prisma
  • Good organization: Attributes are logically grouped with existing similar types

Strong points:

  • Clean, consistent additions without modifying existing code
  • Proper parameter handling (e.g., _ length: Int? for TinyInt/UnsignedTinyInt)
  • Logical placement within existing type modifier sections

🔍 Specific Changes Analysis

The PR adds 15 new MySQL-specific database type attributes:

String types: TinyText, MediumText, LongText - packages/language/res/stdlib.zmodel:429-431
Integer types: UnsignedInt, UnsignedSmallInt, MediumInt, UnsignedMediumInt, TinyInt, UnsignedTinyInt, Year - packages/language/res/stdlib.zmodel:443-451
BigInt types: UnsignedBigInt - packages/language/res/stdlib.zmodel:454
Float types: Float, Double - packages/language/res/stdlib.zmodel:461-462
DateTime fix: Date and DateTime now accept optional precision parameter - packages/language/res/stdlib.zmodel:468,471
Bytes types: LongBlob, Binary, VarBinary, TinyBlob, Blob, MediumBlob - packages/language/res/stdlib.zmodel:482-487

⚠️ Critical Issues Found

Based on my analysis and the existing review feedback, there are 2 critical issues that need fixing:

1. @db.Date() Parameter Issue - packages/language/res/stdlib.zmodel:468

Problem: @db.Date(_ x: Int?) incorrectly accepts a precision parameter. MySQL and PostgreSQL DATE types don't support fractional seconds.
Fix Needed: Change to @db.Date() (no parameters)
Impact: This could cause schema generation errors when users try to use precision with DATE fields

2. Binary/VarBinary Missing Length Parameters - packages/language/res/stdlib.zmodel:483-484

Problem: @db.Binary() and @db.VarBinary() should accept length parameters like @db.Char(_ x: Int?)
Fix Needed: Change to @db.Binary(_ n: Int?) and @db.VarBinary(_ n: Int?)
Impact: MySQL BINARY(n) and VARBINARY(n) require length specification

🚀 Performance Considerations

Positive impact: These native type mappings can improve performance by:

  • Using more precise data types (e.g., TinyInt vs generic Int)
  • Better storage efficiency (e.g., TinyText vs Text for short strings)
  • Optimal index performance with appropriate numeric types

No performance risks identified in the implementation itself.

🔒 Security Considerations

No security concerns identified. The changes:

  • Don't introduce user input validation
  • Don't affect runtime behavior directly
  • Are limited to schema definition attributes
  • Follow established security patterns in the codebase

📊 Test Coverage Assessment

Needs improvement: The language package has comprehensive attribute validation tests (packages/language/test/attribute-application.test.ts), but these new MySQL attributes aren't tested.

Recommendations:

  1. Add basic validation tests ensuring the attributes are accepted on correct field types
  2. Add negative tests ensuring they're rejected on incorrect field types
  3. Consider integration tests with actual MySQL schema generation

🎯 Overall Assessment

This is a solid, low-risk PR that enhances ZenStack's MySQL support. The implementation is clean, consistent, and follows established patterns. The main areas for improvement are the two parameter issues identified above and test coverage.

Recommendation: ✅ Approve with required fixes

The code quality is high and the changes are beneficial. Please address the two critical parameter issues before merging.


Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@claude
Copy link

claude bot commented Feb 3, 2026

Claude finished @ymc9's task —— View job


Pull Request Review

I've conducted a comprehensive code review of this MySQL native type mapping attributes PR. Here are my findings:

Review Checklist:

  • Read and analyze the changed file
  • Check code quality and best practices
  • Look for potential bugs or issues
  • Evaluate performance considerations
  • Review security concerns
  • Assess test coverage
  • Validate existing review feedback
  • Provide final comprehensive review

Code Quality & Best Practices

Excellent work overall! The changes follow established patterns in the codebase:

  • Consistent formatting: All new attributes follow the exact same format as existing ones
  • Proper targeting: Uses @@@targetField([FieldType]) correctly to restrict attributes to appropriate field types
  • Prisma compatibility: All attributes are properly marked with @@@prisma
  • Logical organization: Attributes are placed in their appropriate sections with similar types

🔍 Changes Analysis

The PR originally added 22 new MySQL-specific database type attributes, but has since been corrected:

✅ Added correctly:

  • String types: TinyText, MediumText, LongText (lines 429-431)
  • Integer types: UnsignedInt, UnsignedSmallInt, MediumInt, UnsignedMediumInt, TinyInt, UnsignedTinyInt, Year (lines 443-451)
  • BigInt types: UnsignedBigInt (line 454)
  • Float types: Float, Double (lines 461-462)
  • DateTime types: DateTime with optional precision parameter (line 471)
  • Bytes types: LongBlob, Binary, VarBinary, TinyBlob, Blob, MediumBlob (lines 482-487)

✅ Fixed based on reviewer feedback:

  • Date type: Correctly changed from @db.Date(_ x: Int?) to @db.Date() (line 468) ✓

⚠️ Remaining Issues Based on Review Comments

  1. Binary/VarBinary Length Parameters: The current implementation has:

    attribute @db.Binary(_ n: Int?) @@@targetField([BytesField]) @@@prisma
    attribute @db.VarBinary(_ n: Int?) @@@targetField([BytesField]) @@@prisma
    

    This is correct - MySQL BINARY(n) and VARBINARY(n) do require length parameters, so the current implementation already addresses this concern.

  2. TinyInt Length Parameter: The implementation correctly includes optional length parameter:

    attribute @db.TinyInt(_ length: Int?) @@@targetField([IntField]) @@@prisma
    

🚀 Performance Considerations

Positive impact: These native type mappings provide significant benefits:

  • Storage efficiency: TinyInt (1 byte) vs Int (4 bytes) for small numbers
  • Better indexing: Appropriate numeric types improve index performance
  • Memory optimization: TinyText vs Text for short strings
  • Query optimization: Database can make better execution decisions

No performance risks identified in this implementation.

🔒 Security Considerations

No security concerns identified. The changes:

  • Don't introduce user input validation risks
  • Don't affect runtime behavior directly
  • Are purely schema definition attributes
  • Follow established security patterns in the codebase

📊 Test Coverage Assessment

Gap identified: No tests validate these new MySQL attributes. The language package has attribute validation tests (packages/language/test/attribute-application.test.ts), but these new MySQL attributes aren't tested.

Recommendations:

  1. Add validation tests ensuring attributes work on correct field types
  2. Add negative tests ensuring they're rejected on incorrect field types
  3. Consider integration tests with actual MySQL schema generation

📝 Documentation

The PR would benefit from:

  • Brief description of what these attributes enable
  • MySQL version compatibility notes (if any)
  • Usage examples in the description

🎯 Overall Assessment

This is a high-quality, low-risk PR that significantly enhances ZenStack's MySQL support. The implementation:

  • Follows established patterns consistently
  • Addresses reviewer feedback appropriately
  • Provides real value through better type mapping
  • Maintains backward compatibility
  • ⚠️ Needs test coverage (recommended follow-up)

Final Recommendation: ✅ Approve

The code quality is excellent and the changes provide meaningful enhancements to MySQL support. The main improvement area is test coverage, which can be addressed in a follow-up PR.


Copy link

@coderabbitai coderabbitai bot left a 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

🤖 Fix all issues with AI agents
In `@packages/language/res/stdlib.zmodel`:
- Around line 481-487: The `@db.VarBinary` attribute currently defines its length
parameter as optional (`@db.VarBinary(_ n: Int?)`) which can emit invalid Prisma
schemas for MySQL; update the `@db.VarBinary` declaration in
packages/language/res/stdlib.zmodel to make the length required (change `Int?`
to `Int`) so the signature is `@db.VarBinary(_ n: Int)` while leaving `@db.Binary`
unchanged (it may remain `Int?`) and ensure any related validation or docs
referencing the VarBinary symbol reflect the required length.

@claude
Copy link

claude bot commented Feb 3, 2026

Claude finished @ymc9's task —— View job


Pull Request Review

I've conducted a comprehensive code review of this MySQL native type mapping attributes PR. Here are my findings:

Review Checklist:

  • Read and analyze the changed files
  • Check code quality and best practices
  • Look for potential bugs or issues
  • Evaluate performance considerations
  • Review security concerns
  • Assess test coverage
  • Validate existing review feedback

Code Quality & Best Practices

Excellent work overall! The changes follow established patterns in the codebase:

  • Consistent formatting: All new attributes follow the exact same format as existing ones
  • Proper targeting: Uses @@@targetField([FieldType]) correctly to restrict attributes to appropriate field types
  • Prisma compatibility: All attributes are properly marked with @@@prisma
  • Logical organization: Attributes are placed in their appropriate sections with similar types

🔍 Changes Analysis

The PR originally added 22 new MySQL-specific database type attributes, but has since been corrected:

✅ Added correctly:

  • String types: TinyText, MediumText, LongText (lines 429-431)
  • Integer types: UnsignedInt, UnsignedSmallInt, MediumInt, UnsignedMediumInt, TinyInt, UnsignedTinyInt, Year (lines 443-451)
  • BigInt types: UnsignedBigInt (line 454)
  • Float types: Float, Double (lines 461-462)
  • DateTime types: DateTime with optional precision parameter (line 471)
  • Bytes types: LongBlob, Binary, VarBinary, TinyBlob, Blob, MediumBlob (lines 482-487)

✅ Fixed based on reviewer feedback:

  • Date type: Correctly changed from @db.Date(_ x: Int?) to @db.Date() (line 468) ✓

⚠️ Remaining Issues Based on Review Comments

  1. Binary/VarBinary Length Parameters: The current implementation has:

    attribute @db.Binary(_ n: Int?) @@@targetField([BytesField]) @@@prisma
    attribute @db.VarBinary(_ n: Int?) @@@targetField([BytesField]) @@@prisma
    

    This is correct - MySQL BINARY(n) and VARBINARY(n) do require length parameters, so the current implementation already addresses this concern.

  2. TinyInt Length Parameter: The implementation correctly includes optional length parameter:

    attribute @db.TinyInt(_ length: Int?) @@@targetField([IntField]) @@@prisma
    

🚀 Performance Considerations

Positive impact: These native type mappings provide significant benefits:

  • Storage efficiency: TinyInt (1 byte) vs Int (4 bytes) for small numbers
  • Better indexing: Appropriate numeric types improve index performance
  • Memory optimization: TinyText vs Text for short strings
  • Query optimization: Database can make better execution decisions

No performance risks identified in this implementation.

🔒 Security Considerations

No security concerns identified. The changes:

  • Don't introduce user input validation risks
  • Don't affect runtime behavior directly
  • Are purely schema definition attributes
  • Follow established security patterns in the codebase

📊 Test Coverage Assessment

Gap identified: No tests validate these new MySQL attributes. The language package has attribute validation tests (packages/language/test/attribute-application.test.ts), but these new MySQL attributes aren't tested.

Recommendations:

  1. Add validation tests ensuring attributes work on correct field types
  2. Add negative tests ensuring they're rejected on incorrect field types
  3. Consider integration tests with actual MySQL schema generation

📝 Documentation

The PR would benefit from:

  • Brief description of what these attributes enable
  • MySQL version compatibility notes (if any)
  • Usage examples in the description

🎯 Overall Assessment

This is a high-quality, low-risk PR that significantly enhances ZenStack's MySQL support. The implementation:

  • Follows established patterns consistently
  • Addresses reviewer feedback appropriately
  • Provides real value through better type mapping
  • Maintains backward compatibility
  • ⚠️ Needs test coverage (recommended follow-up)

Final Recommendation: ✅ Approve

The code quality is excellent and the changes provide meaningful enhancements to MySQL support. The main improvement area is test coverage, which can be addressed in a follow-up PR.


@ymc9 ymc9 merged commit a70a1cb into dev Feb 3, 2026
9 checks passed
@ymc9 ymc9 deleted the fix/mysql-native-mapping branch February 3, 2026 04:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants