Skip to content

feat: add optional serde Serialize/Deserialize feature (#115)#416

Draft
MukundaKatta wants to merge 1 commit intoprisma:mainfrom
MukundaKatta:feat/serde-feature
Draft

feat: add optional serde Serialize/Deserialize feature (#115)#416
MukundaKatta wants to merge 1 commit intoprisma:mainfrom
MukundaKatta:feat/serde-feature

Conversation

@MukundaKatta
Copy link
Copy Markdown

Summary

Closes #115. Adds an opt-in serde feature that derives Serialize/Deserialize on Row, Column, ColumnType, TokenRow, ColumnData, Numeric, time types, and XmlData/XmlSchema — so query results can be shipped over the network as JSON. Off by default.

Types covered (all gated behind feature = "serde")

  • Row, Column, ColumnType (src/row.rs)
  • TokenRow<'a> (src/tds/codec/token/token_row.rs)
  • ColumnData<'a> (src/tds/codec/column_data.rs) — Cow<str>, Cow<[u8]>, Uuid, etc.
  • Numeric (src/tds/numeric.rs)
  • DateTime, SmallDateTime, Date, Time, DateTime2, DateTimeOffset (src/tds/time.rs)
  • XmlData, XmlSchema (src/tds/xml.rs)

Feature gating

serde = ["dep:serde", "uuid/serde"] with serde requiring ["derive", "rc"] (rc for Arc<XmlSchema>). Off by default; added to all group. All types use #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] — derive was sufficient throughout, no custom impls needed.

Test plan

  • tests/serde.rs — 17 round-trip tests through serde_json for ColumnType, Column, ColumnData (int/null/string/binary/guid/bool/float/numeric/datetime), Numeric, DateTime, all tds73 time types, XmlData, TokenRow, and a Row-shape flow
  • cargo build (default), cargo build --features serde, cargo build --features all all succeed
  • Lib tests: 117 pass with and without serde
  • cargo fmt --all clean

Adds an opt-in `serde` feature that derives Serialize/Deserialize
on the result-set types, so query results can be sent over the
network as JSON or other serde formats.

Closes prisma#115

Types covered: Row, Column, ColumnType, TokenRow, ColumnData,
Numeric, DateTime, SmallDateTime, Date, Time, DateTime2,
DateTimeOffset, XmlData, XmlSchema. The feature pulls in
serde with the `derive` and `rc` features (for Arc<XmlSchema>)
and enables uuid's serde feature so ColumnData::Guid round-trips.

Adds tests/serde.rs gated on `serde` that round-trips the common
types through serde_json.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 25, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 686bfea7-357d-4e9a-ae1b-0c40969f05e0

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
✨ Simplify code
  • Create PR with simplified code

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.

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.

Add Serde (de)serialization

1 participant