Make time impls opt-in

This commit is contained in:
Steven Fackler 2015-02-07 19:52:45 -08:00
parent b352b12c48
commit 5ec039bd5d
5 changed files with 11 additions and 26 deletions

View File

@ -5,7 +5,7 @@ before_script:
- "./.travis/setup.sh"
script:
- cargo test
- cargo test --features "uuid rustc-serialize"
- cargo test --features "uuid rustc-serialize time"
- cargo doc --no-deps
after_success:
- test $TRAVIS_PULL_REQUEST == "false" && test $TRAVIS_BRANCH == "master" && ./.travis/update_docs.sh

View File

@ -18,16 +18,12 @@ exposes a high level interface in the vein of JDBC or Go's `database/sql`
package.
```rust
extern crate postgres;
extern crate time;
use time::Timespec;
use postgres::{Connection, SslMode};
struct Person {
id: i32,
name: String,
time_created: Timespec,
data: Option<Vec<u8>>
}
@ -38,27 +34,22 @@ fn main() {
conn.execute("CREATE TABLE person (
id SERIAL PRIMARY KEY,
name VARCHAR NOT NULL,
time_created TIMESTAMP NOT NULL,
data BYTEA
)", &[]).unwrap();
let me = Person {
id: 0,
name: "Steven".to_string(),
time_created: time::get_time(),
data: None
};
conn.execute("INSERT INTO person (name, time_created, data)
VALUES ($1, $2, $3)",
&[&me.name, &me.time_created, &me.data]).unwrap();
conn.execute("INSERT INTO person (name, data) VALUES ($1, $2)",
&[&me.name, &me.data]).unwrap();
let stmt = conn.prepare("SELECT id, name, time_created, data FROM person")
.unwrap();
let stmt = conn.prepare("SELECT id, name, data FROM person").unwrap();
for row in stmt.query(&[]).unwrap() {
let person = Person {
id: row.get(0),
name: row.get(1),
time_created: row.get(2),
data: row.get(3)
data: row.get(2)
};
println!("Found person {}", person.name);
}

View File

@ -5,16 +5,12 @@
//! ```rust,no_run
//! # #![allow(unstable)]
//! extern crate postgres;
//! extern crate time;
//!
//! use time::Timespec;
//!
//! use postgres::{Connection, SslMode};
//!
//! struct Person {
//! id: i32,
//! name: String,
//! time_created: Timespec,
//! data: Option<Vec<u8>>
//! }
//!
@ -25,26 +21,22 @@
//! conn.execute("CREATE TABLE person (
//! id SERIAL PRIMARY KEY,
//! name VARCHAR NOT NULL,
//! time_created TIMESTAMP NOT NULL,
//! data BYTEA
//! )", &[]).unwrap();
//! let me = Person {
//! id: 0,
//! name: "Steven".to_string(),
//! time_created: time::get_time(),
//! data: None
//! };
//! conn.execute("INSERT INTO person (name, time_created, data) VALUES ($1, $2, $3)",
//! &[&me.name, &me.time_created, &me.data]).unwrap();
//! conn.execute("INSERT INTO person (name, data) VALUES ($1, $2)",
//! &[&me.name, &me.data]).unwrap();
//!
//! let stmt = conn.prepare("SELECT id, name, time_created, data FROM person")
//! .unwrap();
//! let stmt = conn.prepare("SELECT id, name, data FROM person").unwrap();
//! for row in stmt.query(&[]).unwrap() {
//! let person = Person {
//! id: row.get(0),
//! name: row.get(1),
//! time_created: row.get(2),
//! data: row.get(3)
//! data: row.get(2)
//! };
//! println!("Found person {}", person.name);
//! }

View File

@ -132,6 +132,7 @@ macro_rules! to_raw_to_impl {
#[cfg(feature = "uuid")]
mod uuid;
#[cfg(feature = "time")]
mod time;
mod slice;
#[cfg(feature = "rustc-serialize")]

View File

@ -10,6 +10,7 @@ use postgres::types::{ToSql, FromSql};
#[cfg(feature = "uuid")]
mod uuid;
#[cfg(feature = "time")]
mod time;
#[cfg(feature = "rustc-serialize")]
mod json;