Skip to content

Commit 2893091

Browse files
committed
Merge branch 'release-v0.9.5' into release
2 parents 1ef2e8b + d958316 commit 2893091

File tree

5 files changed

+31
-4
lines changed

5 files changed

+31
-4
lines changed

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
[package]
22
name = "postgres"
3-
version = "0.9.4"
3+
version = "0.9.5"
44
authors = ["Steven Fackler <[email protected]>"]
55
license = "MIT"
66
description = "A native PostgreSQL driver"
77
repository = "https://github.com/sfackler/rust-postgres"
8-
documentation = "https://sfackler.github.io/rust-postgres/doc/v0.9.4/postgres"
8+
documentation = "https://sfackler.github.io/rust-postgres/doc/v0.9.5/postgres"
99
readme = "README.md"
1010
keywords = ["database", "sql"]
1111
build = "build.rs"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Rust-Postgres
22
A native PostgreSQL driver for Rust.
33

4-
[Documentation](https://sfackler.github.io/rust-postgres/doc/v0.9.4/postgres)
4+
[Documentation](https://sfackler.github.io/rust-postgres/doc/v0.9.5/postgres)
55

66
[![Build Status](https://travis-ci.org/sfackler/rust-postgres.png?branch=master)](https://travis-ci.org/sfackler/rust-postgres) [![Latest Version](https://img.shields.io/crates/v/postgres.svg)](https://crates.io/crates/postgres)
77

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
//! }
4242
//! }
4343
//! ```
44-
#![doc(html_root_url="https://sfackler.github.io/rust-postgres/doc/v0.9.4")]
44+
#![doc(html_root_url="https://sfackler.github.io/rust-postgres/doc/v0.9.5")]
4545
#![warn(missing_docs)]
4646

4747
extern crate bufstream;

src/types/mod.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -815,6 +815,25 @@ pub trait ToSql: fmt::Debug {
815815
-> Result<IsNull>;
816816
}
817817

818+
impl<'a, T> ToSql for &'a T where T: ToSql {
819+
fn to_sql_checked(&self, ty: &Type, out: &mut Write, ctx: &SessionInfo)
820+
-> Result<IsNull> {
821+
if !<&'a T as ToSql>::accepts(ty) {
822+
return Err(Error::WrongType(ty.clone()));
823+
}
824+
self.to_sql(ty, out, ctx)
825+
}
826+
827+
828+
fn to_sql<W: Write + ?Sized>(&self, ty: &Type, out: &mut W, ctx: &SessionInfo) -> Result<IsNull> {
829+
(*self).to_sql(ty, out, ctx)
830+
}
831+
832+
fn accepts(ty: &Type) -> bool { T::accepts(ty) }
833+
}
834+
835+
836+
818837
impl<T: ToSql> ToSql for Option<T> {
819838
to_sql_checked!();
820839

tests/types/mod.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,14 @@ fn test_type<T: PartialEq+FromSql+ToSql, S: fmt::Display>(sql_type: &str, checks
3131
}
3232
}
3333

34+
#[test]
35+
fn test_ref_tosql() {
36+
let conn = or_panic!(Connection::connect("postgres://postgres@localhost", &SslMode::None));
37+
let stmt = conn.prepare("SELECT $1::Int").unwrap();
38+
let num: &ToSql = &&7;
39+
stmt.query(&[num]).unwrap();
40+
}
41+
3442
#[test]
3543
fn test_bool_params() {
3644
test_type("BOOL", &[(Some(true), "'t'"), (Some(false), "'f'"),

0 commit comments

Comments
 (0)