Merge branch 'release-v0.9.5' into release

This commit is contained in:
Steven Fackler 2015-08-03 17:15:35 -07:00
commit 2893091266
5 changed files with 31 additions and 4 deletions

View File

@ -1,11 +1,11 @@
[package] [package]
name = "postgres" name = "postgres"
version = "0.9.4" version = "0.9.5"
authors = ["Steven Fackler <sfackler@gmail.com>"] authors = ["Steven Fackler <sfackler@gmail.com>"]
license = "MIT" license = "MIT"
description = "A native PostgreSQL driver" description = "A native PostgreSQL driver"
repository = "https://github.com/sfackler/rust-postgres" repository = "https://github.com/sfackler/rust-postgres"
documentation = "https://sfackler.github.io/rust-postgres/doc/v0.9.4/postgres" documentation = "https://sfackler.github.io/rust-postgres/doc/v0.9.5/postgres"
readme = "README.md" readme = "README.md"
keywords = ["database", "sql"] keywords = ["database", "sql"]
build = "build.rs" build = "build.rs"

View File

@ -1,7 +1,7 @@
# Rust-Postgres # Rust-Postgres
A native PostgreSQL driver for Rust. A native PostgreSQL driver for Rust.
[Documentation](https://sfackler.github.io/rust-postgres/doc/v0.9.4/postgres) [Documentation](https://sfackler.github.io/rust-postgres/doc/v0.9.5/postgres)
[![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) [![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)

View File

@ -41,7 +41,7 @@
//! } //! }
//! } //! }
//! ``` //! ```
#![doc(html_root_url="https://sfackler.github.io/rust-postgres/doc/v0.9.4")] #![doc(html_root_url="https://sfackler.github.io/rust-postgres/doc/v0.9.5")]
#![warn(missing_docs)] #![warn(missing_docs)]
extern crate bufstream; extern crate bufstream;

View File

@ -815,6 +815,25 @@ pub trait ToSql: fmt::Debug {
-> Result<IsNull>; -> Result<IsNull>;
} }
impl<'a, T> ToSql for &'a T where T: ToSql {
fn to_sql_checked(&self, ty: &Type, out: &mut Write, ctx: &SessionInfo)
-> Result<IsNull> {
if !<&'a T as ToSql>::accepts(ty) {
return Err(Error::WrongType(ty.clone()));
}
self.to_sql(ty, out, ctx)
}
fn to_sql<W: Write + ?Sized>(&self, ty: &Type, out: &mut W, ctx: &SessionInfo) -> Result<IsNull> {
(*self).to_sql(ty, out, ctx)
}
fn accepts(ty: &Type) -> bool { T::accepts(ty) }
}
impl<T: ToSql> ToSql for Option<T> { impl<T: ToSql> ToSql for Option<T> {
to_sql_checked!(); to_sql_checked!();

View File

@ -31,6 +31,14 @@ fn test_type<T: PartialEq+FromSql+ToSql, S: fmt::Display>(sql_type: &str, checks
} }
} }
#[test]
fn test_ref_tosql() {
let conn = or_panic!(Connection::connect("postgres://postgres@localhost", &SslMode::None));
let stmt = conn.prepare("SELECT $1::Int").unwrap();
let num: &ToSql = &&7;
stmt.query(&[num]).unwrap();
}
#[test] #[test]
fn test_bool_params() { fn test_bool_params() {
test_type("BOOL", &[(Some(true), "'t'"), (Some(false), "'f'"), test_type("BOOL", &[(Some(true), "'t'"), (Some(false), "'f'"),