feat: add optional serde Serialize/Deserialize feature (#115)#416
Draft
MukundaKatta wants to merge 1 commit intoprisma:mainfrom
Draft
feat: add optional serde Serialize/Deserialize feature (#115)#416MukundaKatta wants to merge 1 commit intoprisma:mainfrom
MukundaKatta wants to merge 1 commit intoprisma:mainfrom
Conversation
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.
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
✨ Simplify 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. Comment |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Closes #115. Adds an opt-in
serdefeature that derivesSerialize/Deserializeon 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 forArc<XmlSchema>). Off by default; added toallgroup. 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 throughserde_jsonfor ColumnType, Column, ColumnData (int/null/string/binary/guid/bool/float/numeric/datetime), Numeric, DateTime, all tds73 time types, XmlData, TokenRow, and a Row-shape flowcargo build(default),cargo build --features serde,cargo build --features allall succeedcargo fmt --allclean