Skip to content

Allow Row to get ColumnData - #304

Closed
LazyDope wants to merge 2 commits into
tiberius-rs:mainfrom
LazyDope:get-coldata
Closed

LazyDope wants to merge 2 commits into
tiberius-rs:mainfrom
LazyDope:get-coldata

Conversation

@LazyDope

Copy link
Copy Markdown
Contributor

When working on data of an unknown type, it's very difficult to get a specific index without explicitly giving the type that we are going to receive. Being able to handle the ColumnData instead of needing to provide a concrete type that implements FromSql allows this to be handled more conveniently.

@ColinFinck

Copy link
Copy Markdown

I second this! Need to query a single cell, but I don't know its result type in advance.
ColumnData would have all the required information, but the stored ColumnData of a Row is currently not exposed. This PR or any similar getter for Row would fix that.

CC @miguelff @pimeys @steffengy @Weakky

@LazyDope

LazyDope commented Aug 1, 2023

Copy link
Copy Markdown
Contributor Author

An acceptable alternative would be implementing FromSql for ColumnData that returns a clone of the ColumnData, but most of the implementation was already present for this, it was just a matter of separating it into its own function.

@bittrance

Copy link
Copy Markdown
Contributor

Does the changes in #303 address this case? Granted, you will have to iterate to the column you want, but unless you have wide result sets or serious performance requirements, that might be acceptable?

@LazyDope

Copy link
Copy Markdown
Contributor Author

No, the borrow checker was not really the problem for me, it is much more straightforward for me to be able to get the data with the column name rather than iterating to the correct column, which is why I make this change in the first place.

MattJackson referenced this pull request in MattJackson/tiberius-ng Aug 29, 2026
- header.rs: allow(dead_code) on PacketHeader::sspi (platform/feature-gated use)
- connection.rs: drop needless reborrow in the zeroizing send path
- row.rs: elide lifetime on get_column_data
- rustfmt negative-numeric formatting from #390
MattJackson added a commit that referenced this pull request Sep 3, 2026
- header.rs: allow(dead_code) on PacketHeader::sspi (platform/feature-gated use)
- connection.rs: drop needless reborrow in the zeroizing send path
- row.rs: elide lifetime on get_column_data
- rustfmt negative-numeric formatting from #390

(cherry picked from commit 09079ca)
MattJackson added a commit that referenced this pull request Sep 4, 2026
- header.rs: allow(dead_code) on PacketHeader::sspi (platform/feature-gated use)
- connection.rs: drop needless reborrow in the zeroizing send path
- row.rs: elide lifetime on get_column_data
- rustfmt negative-numeric formatting from #390

(cherry picked from commit 09079ca)
MattJackson added a commit that referenced this pull request Sep 6, 2026
- header.rs: allow(dead_code) on PacketHeader::sspi (platform/feature-gated use)
- connection.rs: drop needless reborrow in the zeroizing send path
- row.rs: elide lifetime on get_column_data
- rustfmt negative-numeric formatting from #390

(cherry picked from commit 09079ca)
MattJackson added a commit that referenced this pull request Sep 15, 2026
- header.rs: allow(dead_code) on PacketHeader::sspi (platform/feature-gated use)
- connection.rs: drop needless reborrow in the zeroizing send path
- row.rs: elide lifetime on get_column_data
- rustfmt negative-numeric formatting from #390

(cherry picked from commit 09079ca)
MattJackson added a commit that referenced this pull request Sep 16, 2026
- header.rs: allow(dead_code) on PacketHeader::sspi (platform/feature-gated use)
- connection.rs: drop needless reborrow in the zeroizing send path
- row.rs: elide lifetime on get_column_data
- rustfmt negative-numeric formatting from #390

(cherry picked from commit 09079ca)
@MattJackson

Copy link
Copy Markdown
Contributor

Included in #441 — shipped in tiberius v0.13.0. Thanks for this! Closing.

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.

4 participants