mirror of
https://github.com/launchbadge/sqlx.git
synced 2026-04-17 01:44:34 +00:00
implement query_as!() et al, document query macros
This commit is contained in:
committed by
Ryan Leckey
parent
56a82346f2
commit
7d745f98ea
@@ -193,7 +193,7 @@ impl PgConnection {
|
||||
}
|
||||
|
||||
impl PgConnection {
|
||||
async fn open(url: crate::Result<Url>) -> crate::Result<Self> {
|
||||
pub(super) async fn open(url: crate::Result<Url>) -> crate::Result<Self> {
|
||||
let url = url?;
|
||||
let stream = TcpStream::connect((url.host(), url.port(5432))).await?;
|
||||
let mut self_ = Self {
|
||||
|
||||
@@ -10,3 +10,5 @@ impl Database for Postgres {
|
||||
|
||||
type Row = super::PgRow;
|
||||
}
|
||||
|
||||
impl_into_arguments_for_database!(Postgres);
|
||||
|
||||
@@ -291,13 +291,9 @@ impl super::PgConnection {
|
||||
name: field.name,
|
||||
table_id: field.table_id,
|
||||
type_id: field.type_id,
|
||||
|
||||
_non_exhaustive: (),
|
||||
})
|
||||
.collect::<Vec<_>>()
|
||||
.into_boxed_slice(),
|
||||
|
||||
_non_exhaustive: (),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,15 @@
|
||||
//! **Postgres** database and connection types.
|
||||
|
||||
use std::convert::TryInto;
|
||||
|
||||
pub use arguments::PgArguments;
|
||||
pub use connection::PgConnection;
|
||||
pub use database::Postgres;
|
||||
pub use error::PgError;
|
||||
pub use row::PgRow;
|
||||
|
||||
use crate::url::Url;
|
||||
|
||||
mod arguments;
|
||||
mod connection;
|
||||
mod database;
|
||||
@@ -9,15 +19,14 @@ mod protocol;
|
||||
mod row;
|
||||
mod types;
|
||||
|
||||
pub use database::Postgres;
|
||||
|
||||
pub use arguments::PgArguments;
|
||||
|
||||
pub use connection::PgConnection;
|
||||
|
||||
pub use error::PgError;
|
||||
|
||||
pub use row::PgRow;
|
||||
|
||||
/// An alias for [`Pool`], specialized for **Postgres**.
|
||||
pub type PgPool = super::Pool<Postgres>;
|
||||
|
||||
// used in tests and hidden code in examples
|
||||
#[doc(hidden)]
|
||||
pub async fn connect<T>(url: T) -> crate::Result<PgConnection>
|
||||
where
|
||||
T: TryInto<Url, Error = crate::Error>
|
||||
{
|
||||
PgConnection::open(url.try_into()).await
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user