Skip to content

Commit 5ec039b

Browse files
committed
Make time impls opt-in
1 parent b352b12 commit 5ec039b

5 files changed

Lines changed: 11 additions & 26 deletions

File tree

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ before_script:
55
- "./.travis/setup.sh"
66
script:
77
- cargo test
8-
- cargo test --features "uuid rustc-serialize"
8+
- cargo test --features "uuid rustc-serialize time"
99
- cargo doc --no-deps
1010
after_success:
1111
- test $TRAVIS_PULL_REQUEST == "false" && test $TRAVIS_BRANCH == "master" && ./.travis/update_docs.sh

README.md

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,12 @@ exposes a high level interface in the vein of JDBC or Go's `database/sql`
1818
package.
1919
```rust
2020
extern crate postgres;
21-
extern crate time;
22-
23-
use time::Timespec;
2421

2522
use postgres::{Connection, SslMode};
2623

2724
struct Person {
2825
id: i32,
2926
name: String,
30-
time_created: Timespec,
3127
data: Option<Vec<u8>>
3228
}
3329

@@ -38,27 +34,22 @@ fn main() {
3834
conn.execute("CREATE TABLE person (
3935
id SERIAL PRIMARY KEY,
4036
name VARCHAR NOT NULL,
41-
time_created TIMESTAMP NOT NULL,
4237
data BYTEA
4338
)", &[]).unwrap();
4439
let me = Person {
4540
id: 0,
4641
name: "Steven".to_string(),
47-
time_created: time::get_time(),
4842
data: None
4943
};
50-
conn.execute("INSERT INTO person (name, time_created, data)
51-
VALUES ($1, $2, $3)",
52-
&[&me.name, &me.time_created, &me.data]).unwrap();
44+
conn.execute("INSERT INTO person (name, data) VALUES ($1, $2)",
45+
&[&me.name, &me.data]).unwrap();
5346

54-
let stmt = conn.prepare("SELECT id, name, time_created, data FROM person")
55-
.unwrap();
47+
let stmt = conn.prepare("SELECT id, name, data FROM person").unwrap();
5648
for row in stmt.query(&[]).unwrap() {
5749
let person = Person {
5850
id: row.get(0),
5951
name: row.get(1),
60-
time_created: row.get(2),
61-
data: row.get(3)
52+
data: row.get(2)
6253
};
6354
println!("Found person {}", person.name);
6455
}

src/lib.rs

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,12 @@
55
//! ```rust,no_run
66
//! # #![allow(unstable)]
77
//! extern crate postgres;
8-
//! extern crate time;
9-
//!
10-
//! use time::Timespec;
118
//!
129
//! use postgres::{Connection, SslMode};
1310
//!
1411
//! struct Person {
1512
//! id: i32,
1613
//! name: String,
17-
//! time_created: Timespec,
1814
//! data: Option<Vec<u8>>
1915
//! }
2016
//!
@@ -25,26 +21,22 @@
2521
//! conn.execute("CREATE TABLE person (
2622
//! id SERIAL PRIMARY KEY,
2723
//! name VARCHAR NOT NULL,
28-
//! time_created TIMESTAMP NOT NULL,
2924
//! data BYTEA
3025
//! )", &[]).unwrap();
3126
//! let me = Person {
3227
//! id: 0,
3328
//! name: "Steven".to_string(),
34-
//! time_created: time::get_time(),
3529
//! data: None
3630
//! };
37-
//! conn.execute("INSERT INTO person (name, time_created, data) VALUES ($1, $2, $3)",
38-
//! &[&me.name, &me.time_created, &me.data]).unwrap();
31+
//! conn.execute("INSERT INTO person (name, data) VALUES ($1, $2)",
32+
//! &[&me.name, &me.data]).unwrap();
3933
//!
40-
//! let stmt = conn.prepare("SELECT id, name, time_created, data FROM person")
41-
//! .unwrap();
34+
//! let stmt = conn.prepare("SELECT id, name, data FROM person").unwrap();
4235
//! for row in stmt.query(&[]).unwrap() {
4336
//! let person = Person {
4437
//! id: row.get(0),
4538
//! name: row.get(1),
46-
//! time_created: row.get(2),
47-
//! data: row.get(3)
39+
//! data: row.get(2)
4840
//! };
4941
//! println!("Found person {}", person.name);
5042
//! }

src/types/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ macro_rules! to_raw_to_impl {
132132

133133
#[cfg(feature = "uuid")]
134134
mod uuid;
135+
#[cfg(feature = "time")]
135136
mod time;
136137
mod slice;
137138
#[cfg(feature = "rustc-serialize")]

tests/types/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use postgres::types::{ToSql, FromSql};
1010

1111
#[cfg(feature = "uuid")]
1212
mod uuid;
13+
#[cfg(feature = "time")]
1314
mod time;
1415
#[cfg(feature = "rustc-serialize")]
1516
mod json;

0 commit comments

Comments
 (0)