Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Proposal] Expose column information on Row #181

Closed
mehcode opened this issue Mar 30, 2020 · 1 comment
Closed

[Proposal] Expose column information on Row #181

mehcode opened this issue Mar 30, 2020 · 1 comment
Labels

Comments

@mehcode
Copy link
Member

mehcode commented Mar 30, 2020

struct Column<'r, DB> {
  pub name: Option<&'r str>,
  pub type_info: Option<DB::TypeInfo>,
}

trait Row {
  // [...]

  // Get all columns
  fn columns(&self) -> &[Column<Self::Database>];

  // Get a column by name or position
  fn column(&self, index: impl ColumnIndex) -> Option<&Column<Self::Database>>;
}
  • All this information is already available (and cached on the prepared statement per connection)
@mehcode mehcode changed the title Expose column information on Row [Proposal] Expose column information on Row Mar 30, 2020
zaynetro added a commit to zaynetro/sqlx that referenced this issue Apr 30, 2020
This is my attempt to fix launchbadge#181 .

I am not sure if you have the same implementation in mind so let me know if I am
on the right track.

I was not sure how to verify the column type in tests as I couldn't construct
`MySqlTypeInfo` due to `TypeId` being crate-private.
zaynetro added a commit to zaynetro/sqlx that referenced this issue Apr 30, 2020
This is my attempt to fix launchbadge#181 .

I am not sure if you have the same implementation in mind so let me know if I am
on the right track.

I was not sure how to verify the column type in tests as I couldn't construct
`MySqlTypeInfo` due to `TypeId` being crate-private.
@mehcode
Copy link
Member Author

mehcode commented Jul 5, 2020

This is now available on master. See #292 (comment) for more information.

@mehcode mehcode closed this as completed Jul 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant