Skip to content

Commit 9a6cf0a

Browse files
committed
Merge branch 'release-v0.2.0' into release
2 parents 0fcde21 + f7ef155 commit 9a6cf0a

File tree

3 files changed

+23
-19
lines changed

3 files changed

+23
-19
lines changed

Cargo.toml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
[package]
22
name = "postgres-binary-copy"
3-
version = "0.1.2"
3+
version = "0.2.0"
44
authors = ["Steven Fackler <sfackler@gmail.com>"]
55
license = "MIT"
66
description = "Support for binary-format COPY query execution with postgres"
7-
documentation = "https://sfackler.github.io/rust-postgres-binary-copy/doc/v0.1.2/postgres_binary_copy"
7+
documentation = "https://sfackler.github.io/rust-postgres-binary-copy/doc/v0.2.0/postgres_binary_copy"
8+
repository = "https://github.com/sfackler/rust-postgres-binary-copy"
89
readme = "README.md"
910
keywords = ["database", "sql", "postgres", "copy"]
1011

1112
[dependencies]
1213
byteorder = ">= 0.3, < 0.5"
13-
postgres = "0.10"
14+
postgres = "0.11"

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
Support for binary-format `COPY` query execution with
66
[rust-postgres](https://github.com/sfackler/rust-postgres).
77

8-
[Documentation](https://sfackler.github.io/rust-postgres-binary-copy/doc/v0.1.2/postgres_binary_copy)
8+
[Documentation](https://sfackler.github.io/rust-postgres-binary-copy/doc/v0.2.0/postgres_binary_copy)
99

1010
## Example
1111

@@ -19,7 +19,7 @@ use postgres_binary_copy::BinaryCopyReader;
1919

2020
fn main() {
2121
let conn = Connection::connect("postgres://postgres@localhost",
22-
&SslMode::None).unwrap();
22+
SslMode::None).unwrap();
2323

2424
conn.execute("CREATE TABLE foo (id INT PRIMARY KEY, bar VARCHAR)", &[])
2525
.unwrap();

src/lib.rs

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
//!
1313
//! fn main() {
1414
//! let conn = Connection::connect("postgres://postgres@localhost",
15-
//! &SslMode::None).unwrap();
15+
//! SslMode::None).unwrap();
1616
//!
1717
//! conn.execute("CREATE TABLE foo (id INT PRIMARY KEY, bar VARCHAR)", &[])
1818
//! .unwrap();
@@ -27,7 +27,7 @@
2727
//! stmt.copy_in(&[], &mut reader).unwrap();
2828
//! }
2929
//! ```
30-
#![doc(html_root_url="https://sfackler.github.io/rust-postgres-binary-copy/doc/v0.1.2")]
30+
#![doc(html_root_url="https://sfackler.github.io/rust-postgres-binary-copy/doc/v0.2.0")]
3131
#![warn(missing_docs)]
3232
extern crate byteorder;
3333
extern crate postgres;
@@ -399,7 +399,7 @@ mod test {
399399

400400
#[test]
401401
fn write_basic() {
402-
let conn = Connection::connect("postgres://postgres@localhost", &SslMode::None).unwrap();
402+
let conn = Connection::connect("postgres://postgres@localhost", SslMode::None).unwrap();
403403
conn.execute("CREATE TEMPORARY TABLE foo (id INT PRIMARY KEY, bar VARCHAR)", &[]).unwrap();
404404

405405
let stmt = conn.prepare("COPY foo (id, bar) FROM STDIN BINARY").unwrap();
@@ -423,7 +423,7 @@ mod test {
423423

424424
#[test]
425425
fn write_many_rows() {
426-
let conn = Connection::connect("postgres://postgres@localhost", &SslMode::None).unwrap();
426+
let conn = Connection::connect("postgres://postgres@localhost", SslMode::None).unwrap();
427427
conn.execute("CREATE TEMPORARY TABLE foo (id INT PRIMARY KEY, bar VARCHAR)", &[]).unwrap();
428428

429429
let stmt = conn.prepare("COPY foo (id, bar) FROM STDIN BINARY").unwrap();
@@ -451,7 +451,7 @@ mod test {
451451

452452
#[test]
453453
fn write_big_rows() {
454-
let conn = Connection::connect("postgres://postgres@localhost", &SslMode::None).unwrap();
454+
let conn = Connection::connect("postgres://postgres@localhost", SslMode::None).unwrap();
455455
conn.execute("CREATE TEMPORARY TABLE foo (id INT PRIMARY KEY, bar BYTEA)", &[]).unwrap();
456456

457457
let stmt = conn.prepare("COPY foo (id, bar) FROM STDIN BINARY").unwrap();
@@ -479,15 +479,18 @@ mod test {
479479

480480
#[test]
481481
fn read_basic() {
482-
let conn = Connection::connect("postgres://postgres@localhost", &SslMode::None).unwrap();
482+
let conn = Connection::connect("postgres://postgres@localhost", SslMode::None).unwrap();
483483
conn.execute("CREATE TEMPORARY TABLE foo (id SERIAL PRIMARY KEY, bar INT)", &[]).unwrap();
484484
conn.execute("INSERT INTO foo (bar) VALUES (1), (2), (NULL), (4)", &[]).unwrap();
485485

486486
let mut out = vec![];
487487

488488
{
489489
let writer = |r: Option<&mut WriteValueReader>, info: &CopyInfo| {
490-
out.push(Option::<i32>::from_sql_nullable(&Type::Int4, r, &info.session_info()).unwrap());
490+
match r {
491+
Some(r) => out.push(Option::<i32>::from_sql(&Type::Int4, r, &info.session_info()).unwrap()),
492+
None => out.push(Option::<i32>::from_sql_null(&Type::Int4, &info.session_info()).unwrap()),
493+
}
491494
Ok(())
492495
};
493496

@@ -502,7 +505,7 @@ mod test {
502505

503506
#[test]
504507
fn read_many_rows() {
505-
let conn = Connection::connect("postgres://postgres@localhost", &SslMode::None).unwrap();
508+
let conn = Connection::connect("postgres://postgres@localhost", SslMode::None).unwrap();
506509
conn.execute("CREATE TEMPORARY TABLE foo (id INT)", &[]).unwrap();
507510

508511
let mut expected = vec![];
@@ -516,7 +519,7 @@ mod test {
516519

517520
{
518521
let writer = |r: Option<&mut WriteValueReader>, info: &CopyInfo| {
519-
out.push(i32::from_sql_nullable(&Type::Int4, r, &info.session_info()).unwrap());
522+
out.push(i32::from_sql(&Type::Int4, r.unwrap(), &info.session_info()).unwrap());
520523
Ok(())
521524
};
522525

@@ -531,7 +534,7 @@ mod test {
531534

532535
#[test]
533536
fn read_big_rows() {
534-
let conn = Connection::connect("postgres://postgres@localhost", &SslMode::None).unwrap();
537+
let conn = Connection::connect("postgres://postgres@localhost", SslMode::None).unwrap();
535538
conn.execute("CREATE TEMPORARY TABLE foo (id INT PRIMARY KEY, bar BYTEA)", &[]).unwrap();
536539

537540
let mut expected = vec![];
@@ -546,7 +549,7 @@ mod test {
546549

547550
{
548551
let writer = |r: Option<&mut WriteValueReader>, info: &CopyInfo| {
549-
out.push(Vec::<u8>::from_sql_nullable(&Type::Bytea, r, &info.session_info()).unwrap());
552+
out.push(Vec::<u8>::from_sql(&Type::Bytea, r.unwrap(), &info.session_info()).unwrap());
550553
Ok(())
551554
};
552555

@@ -561,7 +564,7 @@ mod test {
561564

562565
#[test]
563566
fn read_with_oids() {
564-
let conn = Connection::connect("postgres://postgres@localhost", &SslMode::None).unwrap();
567+
let conn = Connection::connect("postgres://postgres@localhost", SslMode::None).unwrap();
565568
conn.execute("CREATE TEMPORARY TABLE foo (id INT) WITH OIDS", &[]).unwrap();
566569
conn.execute("INSERT INTO foo (id) VALUES (1), (2), (3), (4)", &[]).unwrap();
567570

@@ -571,9 +574,9 @@ mod test {
571574
{
572575
let writer = |r: Option<&mut WriteValueReader>, info: &CopyInfo| {
573576
if oids.len() > out.len() {
574-
out.push(i32::from_sql_nullable(&Type::Bytea, r, &info.session_info()).unwrap());
577+
out.push(i32::from_sql(&Type::Bytea, r.unwrap(), &info.session_info()).unwrap());
575578
} else {
576-
oids.push(u32::from_sql_nullable(&Type::Oid, r, &info.session_info()).unwrap());
579+
oids.push(u32::from_sql(&Type::Oid, r.unwrap(), &info.session_info()).unwrap());
577580
}
578581
Ok(())
579582
};

0 commit comments

Comments
 (0)