Remove custom UDT marshaling code, rely on gocql defaults#102
Conversation
gocql already provides a reflection-based UDT marshaler that reads the `cql:"..."` struct tag. The custom marshalUDTField/unmarshalUDTField helpers and the per-UDT MarshalUDT/UnmarshalUDT methods delegating to them were reimplementing behaviour the driver does natively — all that was actually needed was the existing `cql` tags. This mirrors the same simplification applied to message-worker's cassParticipant in PR #95. - Delete pkg/model/cassandra/udt.go (helpers + verifyUDTTags) - Delete pkg/model/cassandra/udt_test.go - Remove MarshalUDT/UnmarshalUDT methods and init() from message.go - Drop two obsolete tests in message_test.go https://claude.ai/code/session_01XKyoiWJDNWWkNc29RixBqJ
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
💤 Files with no reviewable changes (3)
📝 WalkthroughWalkthroughThis change removes custom UDT marshaling/unmarshaling method implementations from Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
Summary
This PR removes the custom User-Defined Type (UDT) marshaling/unmarshaling implementation and helper functions, allowing gocql's built-in reflection-based UDT marshaler to handle the serialization automatically. The
cqlstruct tags on all UDT types already provide the necessary field mapping information.Key Changes
Removed files:
pkg/model/cassandra/udt.go- Custom marshaling helper functions (unmarshalUDTField,marshalUDTField,verifyUDTTags)pkg/model/cassandra/udt_test.go- All associated unit testsModified
pkg/model/cassandra/message.go:init()function that calledverifyUDTTags()for each UDT typeUnmarshalUDT()andMarshalUDT()method implementations fromParticipant,File,Card,CardAction, andQuotedParentMessagetypescqlstruct tags are used by gocql's reflection-based marshaler to map Go fields to Cassandra UDT field namesModified
pkg/model/cassandra/message_test.go:UnmarshalUDT()andMarshalUDT()methodsImplementation Details
The
cqlstruct tags on all UDT struct fields already contain the correct Cassandra column name mappings (e.g.,cql:"eng_name"for theEngNamefield). gocql's default reflection-based UDT marshaler uses these tags automatically, making the custom implementation redundant. This simplification reduces code complexity while maintaining the same functionality.https://claude.ai/code/session_01XKyoiWJDNWWkNc29RixBqJ
Summary by CodeRabbit