Skip to content
This repository has been archived by the owner on Apr 13, 2021. It is now read-only.

Commit

Permalink
use PgType instead of Oid (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-dukhno authored Nov 4, 2020
1 parent 3643160 commit 65e2d58
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

use crate::{cursor::Cursor, ConnId, ConnSecretKey, Error, Oid, PgFormat, Result, UnrecognizedFormat};
use crate::{cursor::Cursor, types::PgType, ConnId, ConnSecretKey, Error, PgFormat, Result, UnrecognizedFormat};
use std::convert::TryFrom;

const COMMAND_COMPLETE: u8 = b'C';
Expand Down Expand Up @@ -235,7 +235,7 @@ pub enum BackendMessage {
/// 3rd and 4th paragraph
ParameterStatus(String, String),
/// Indicates that parameters are needed by a prepared statement.
ParameterDescription(Vec<Oid>),
ParameterDescription(Vec<PgType>),
/// Indicates that the statement will not return rows.
NoData,
/// This message informs the frontend about the previous `Parse` frontend
Expand Down Expand Up @@ -341,15 +341,15 @@ impl BackendMessage {
parameter_status_buff.extend_from_slice(parameters.as_ref());
parameter_status_buff
}
BackendMessage::ParameterDescription(type_ids) => {
BackendMessage::ParameterDescription(pg_types) => {
let mut type_id_buff = Vec::new();
for type_id in type_ids.iter() {
type_id_buff.extend_from_slice(&type_id.to_be_bytes());
for pg_type in pg_types.iter() {
type_id_buff.extend_from_slice(&pg_type.type_oid().to_be_bytes());
}
let mut buff = Vec::new();
buff.extend_from_slice(&[PARAMETER_DESCRIPTION]);
buff.extend_from_slice(&(6 + type_id_buff.len() as i32).to_be_bytes());
buff.extend_from_slice(&(type_ids.len() as i16).to_be_bytes());
buff.extend_from_slice(&(pg_types.len() as i16).to_be_bytes());
buff.extend_from_slice(&type_id_buff);
buff
}
Expand Down Expand Up @@ -787,7 +787,7 @@ mod serializing_backend_messages {
#[test]
fn parameter_description() {
assert_eq!(
BackendMessage::ParameterDescription(vec![23]).as_vec(),
BackendMessage::ParameterDescription(vec![PgType::Integer]).as_vec(),
vec![PARAMETER_DESCRIPTION, 0, 0, 0, 10, 0, 1, 0, 0, 0, 23]
)
}
Expand Down

0 comments on commit 65e2d58

Please # to comment.