Deprecate batch_execute
It's being replaced by the more capable `simple_query` API.
This commit is contained in:
parent
aeaea5e38e
commit
39a4cdfa82
@ -1304,7 +1304,8 @@ impl Connection {
|
||||
pub fn set_transaction_config(&self, config: &transaction::Config) -> Result<()> {
|
||||
let mut command = "SET SESSION CHARACTERISTICS AS TRANSACTION".to_owned();
|
||||
config.build_command(&mut command);
|
||||
self.batch_execute(&command)
|
||||
self.simple_query(&command)
|
||||
.map(|_| ())
|
||||
}
|
||||
|
||||
/// Execute a sequence of SQL statements.
|
||||
@ -1341,6 +1342,7 @@ impl Connection {
|
||||
/// CREATE INDEX ON purchase (time);
|
||||
/// ").unwrap();
|
||||
/// ```
|
||||
#[deprecated(since="0.15.3", note="please use `simple_query` instead")]
|
||||
pub fn batch_execute(&self, query: &str) -> Result<()> {
|
||||
self.0.borrow_mut().quick_query(query).map(|_| ())
|
||||
}
|
||||
@ -1449,6 +1451,7 @@ pub trait GenericConnection {
|
||||
fn transaction<'a>(&'a self) -> Result<Transaction<'a>>;
|
||||
|
||||
/// Like `Connection::batch_execute`.
|
||||
#[deprecated(since="0.15.3", note="please use `simple_query` instead")]
|
||||
fn batch_execute(&self, query: &str) -> Result<()>;
|
||||
|
||||
/// Like `Connection::is_active`.
|
||||
@ -1480,7 +1483,8 @@ impl GenericConnection for Connection {
|
||||
}
|
||||
|
||||
fn batch_execute(&self, query: &str) -> Result<()> {
|
||||
self.batch_execute(&query)
|
||||
self.simple_query(query)
|
||||
.map(|_| ())
|
||||
}
|
||||
|
||||
fn is_active(&self) -> bool {
|
||||
@ -1514,7 +1518,8 @@ impl<'a> GenericConnection for Transaction<'a> {
|
||||
}
|
||||
|
||||
fn batch_execute(&self, query: &str) -> Result<()> {
|
||||
self.batch_execute(&query)
|
||||
self.simple_query(query)
|
||||
.map(|_| ())
|
||||
}
|
||||
|
||||
fn simple_query(&self, query: &str) -> Result<Vec<TextRows>> {
|
||||
|
@ -226,8 +226,10 @@ impl<'conn> Transaction<'conn> {
|
||||
}
|
||||
|
||||
/// Like `Connection::batch_execute`.
|
||||
#[deprecated(since="0.15.3", note="please use `simple_query` instead")]
|
||||
pub fn batch_execute(&self, query: &str) -> Result<()> {
|
||||
self.conn.batch_execute(query)
|
||||
self.simple_query(query)
|
||||
.map(|_| ())
|
||||
}
|
||||
|
||||
/// Like `Connection::simple_query`.
|
||||
@ -283,7 +285,8 @@ impl<'conn> Transaction<'conn> {
|
||||
pub fn set_config(&self, config: &Config) -> Result<()> {
|
||||
let mut command = "SET TRANSACTION".to_owned();
|
||||
config.build_command(&mut command);
|
||||
self.batch_execute(&command).map(|_| ())
|
||||
self.simple_query(&command)
|
||||
.map(|_| ())
|
||||
}
|
||||
|
||||
/// Determines if the transaction is currently set to commit or roll back.
|
||||
|
@ -396,6 +396,7 @@ fn test_stmt_finish() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[allow(deprecated)]
|
||||
fn test_batch_execute() {
|
||||
let conn = or_panic!(Connection::connect(
|
||||
"postgres://postgres@localhost:5433",
|
||||
@ -415,6 +416,7 @@ fn test_batch_execute() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[allow(deprecated)]
|
||||
fn test_batch_execute_error() {
|
||||
let conn = or_panic!(Connection::connect(
|
||||
"postgres://postgres@localhost:5433",
|
||||
@ -435,6 +437,7 @@ fn test_batch_execute_error() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[allow(deprecated)]
|
||||
fn test_transaction_batch_execute() {
|
||||
let conn = or_panic!(Connection::connect(
|
||||
"postgres://postgres@localhost:5433",
|
||||
@ -1091,6 +1094,7 @@ fn test_execute_copy_from_err() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[allow(deprecated)]
|
||||
fn test_batch_execute_copy_from_err() {
|
||||
let conn = or_panic!(Connection::connect(
|
||||
"postgres://postgres@localhost:5433",
|
||||
@ -1156,7 +1160,7 @@ fn test_query_copy_out_err() {
|
||||
"postgres://postgres@localhost:5433",
|
||||
TlsMode::None,
|
||||
));
|
||||
or_panic!(conn.batch_execute(
|
||||
or_panic!(conn.simple_query(
|
||||
"
|
||||
CREATE TEMPORARY TABLE foo (id INT);
|
||||
INSERT INTO foo (id) VALUES (0), (1), (2), (3)",
|
||||
@ -1175,7 +1179,7 @@ fn test_copy_out() {
|
||||
"postgres://postgres@localhost:5433",
|
||||
TlsMode::None,
|
||||
));
|
||||
or_panic!(conn.batch_execute(
|
||||
or_panic!(conn.simple_query(
|
||||
"
|
||||
CREATE TEMPORARY TABLE foo (id INT);
|
||||
INSERT INTO foo (id) VALUES (0), (1), (2), (3)",
|
||||
@ -1185,7 +1189,7 @@ fn test_copy_out() {
|
||||
let count = or_panic!(stmt.copy_out(&[], &mut buf));
|
||||
assert_eq!(count, 4);
|
||||
assert_eq!(buf, b"0\n1\n2\n3\n");
|
||||
or_panic!(conn.batch_execute("SELECT 1"));
|
||||
or_panic!(conn.simple_query("SELECT 1"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -1194,7 +1198,7 @@ fn test_copy_out_error() {
|
||||
"postgres://postgres@localhost:5433",
|
||||
TlsMode::None,
|
||||
));
|
||||
or_panic!(conn.batch_execute(
|
||||
or_panic!(conn.simple_query(
|
||||
"
|
||||
CREATE TEMPORARY TABLE foo (id INT);
|
||||
INSERT INTO foo (id) VALUES (0), (1), (2), (3)",
|
||||
@ -1380,7 +1384,7 @@ fn test_transaction_isolation_level() {
|
||||
#[test]
|
||||
fn test_rows_index() {
|
||||
let conn = Connection::connect("postgres://postgres@localhost:5433", TlsMode::None).unwrap();
|
||||
conn.batch_execute(
|
||||
conn.simple_query(
|
||||
"
|
||||
CREATE TEMPORARY TABLE foo (id INT PRIMARY KEY);
|
||||
INSERT INTO foo (id) VALUES (1), (2), (3);
|
||||
@ -1413,7 +1417,7 @@ fn test_type_names() {
|
||||
#[test]
|
||||
fn test_conn_query() {
|
||||
let conn = Connection::connect("postgres://postgres@localhost:5433", TlsMode::None).unwrap();
|
||||
conn.batch_execute(
|
||||
conn.simple_query(
|
||||
"
|
||||
CREATE TEMPORARY TABLE foo (id INT PRIMARY KEY);
|
||||
INSERT INTO foo (id) VALUES (1), (2), (3);
|
||||
@ -1492,7 +1496,7 @@ fn explicit_types() {
|
||||
#[test]
|
||||
fn simple_query() {
|
||||
let conn = Connection::connect("postgres://postgres@localhost:5433", TlsMode::None).unwrap();
|
||||
conn.batch_execute(
|
||||
conn.simple_query(
|
||||
"
|
||||
CREATE TEMPORARY TABLE foo (id INT PRIMARY KEY);
|
||||
INSERT INTO foo (id) VALUES (1), (2), (3);
|
||||
|
@ -362,7 +362,7 @@ fn test_pg_database_datname() {
|
||||
#[test]
|
||||
fn test_slice() {
|
||||
let conn = Connection::connect("postgres://postgres@localhost:5433", TlsMode::None).unwrap();
|
||||
conn.batch_execute(
|
||||
conn.simple_query(
|
||||
"CREATE TEMPORARY TABLE foo (id SERIAL PRIMARY KEY, f VARCHAR);
|
||||
INSERT INTO foo (f) VALUES ('a'), ('b'), ('c'), ('d');",
|
||||
).unwrap();
|
||||
@ -382,7 +382,7 @@ fn test_slice() {
|
||||
#[test]
|
||||
fn test_slice_wrong_type() {
|
||||
let conn = Connection::connect("postgres://postgres@localhost:5433", TlsMode::None).unwrap();
|
||||
conn.batch_execute("CREATE TEMPORARY TABLE foo (id SERIAL PRIMARY KEY)")
|
||||
conn.simple_query("CREATE TEMPORARY TABLE foo (id SERIAL PRIMARY KEY)")
|
||||
.unwrap();
|
||||
|
||||
let stmt = conn.prepare("SELECT * FROM foo WHERE id = ANY($1)")
|
||||
@ -449,7 +449,7 @@ fn domain() {
|
||||
}
|
||||
|
||||
let conn = Connection::connect("postgres://postgres@localhost:5433", TlsMode::None).unwrap();
|
||||
conn.batch_execute(
|
||||
conn.simple_query(
|
||||
"CREATE DOMAIN pg_temp.session_id AS bytea CHECK(octet_length(VALUE) = 16);
|
||||
CREATE TABLE pg_temp.foo (id pg_temp.session_id);",
|
||||
).unwrap();
|
||||
@ -464,7 +464,7 @@ fn domain() {
|
||||
#[test]
|
||||
fn composite() {
|
||||
let conn = Connection::connect("postgres://postgres@localhost:5433", TlsMode::None).unwrap();
|
||||
conn.batch_execute(
|
||||
conn.simple_query(
|
||||
"CREATE TYPE pg_temp.inventory_item AS (
|
||||
name TEXT,
|
||||
supplier INTEGER,
|
||||
@ -491,7 +491,7 @@ fn composite() {
|
||||
#[test]
|
||||
fn enum_() {
|
||||
let conn = Connection::connect("postgres://postgres@localhost:5433", TlsMode::None).unwrap();
|
||||
conn.batch_execute("CREATE TYPE pg_temp.mood AS ENUM ('sad', 'ok', 'happy');")
|
||||
conn.simple_query("CREATE TYPE pg_temp.mood AS ENUM ('sad', 'ok', 'happy');")
|
||||
.unwrap();
|
||||
|
||||
let stmt = conn.prepare("SELECT $1::mood").unwrap();
|
||||
|
Loading…
Reference in New Issue
Block a user