pub fn normalize(statement: &str) -> Result<String> {
    let input = CString::new(statement).unwrap();
    let result = unsafe { pg_query_normalize(input.as_ptr() as *const c_char) };
    let normalized_query = if !result.error.is_null() {
        let message = unsafe { CStr::from_ptr((*result.error).message) }.to_string_lossy().to_string();
        return Err(Error::Parse(message));
    } else {
        let n = unsafe { CStr::from_ptr(result.normalized_query) };
        Ok(n.to_string_lossy().to_string())
    };
    unsafe { pg_query_free_normalize_result(result) };
    normalized_query
}
/// Normalizes the given SQL statement, returning a parametized version.
///
/// # Example
///
/// ```rust
/// let result = pg_query::normalize("SELECT * FROM contacts WHERE name='Paul'");
/// assert!(result.is_ok());
/// let result = result.unwrap();
/// assert_eq!(result, "SELECT * FROM contacts WHERE name=$1");
/// ```
Normalizes the given SQL statement, returning a parametized version.
Normalizes the given SQL statement returning a parametized version .
pub fn normalize(statement: &str) -> Result<String> {
    let input = CString::new(statement).unwrap();
    let result = unsafe { pg_query_normalize(input.as_ptr() as *const c_char) };
    let normalized_query = if !result.error.is_null() {
        let message = unsafe { CStr::from_ptr((*result.error).message) }.to_string_lossy().to_string();
        return Err(Error::Parse(message));
    } else {
        let n = unsafe { CStr::from_ptr(result.normalized_query) };
        Ok(n.to_string_lossy().to_string())
    };
    unsafe { pg_query_free_normalize_result(result) };
    normalized_query
}
pub fn normalize ( statement : & str ) -> Result < String > { let input = CString :: new ( statement ) . unwrap ( ) ; let result = unsafe { pg_query_normalize ( input . as_ptr ( ) as * const c_char ) } ; let normalized_query = if ! result . error . is_null ( ) { let message = unsafe { CStr :: from_ptr ( ( * result . error ) . message ) } . to_string_lossy ( ) . to_string ( ) ; return Err ( Error :: Parse ( message ) ) ; } else { let n = unsafe { CStr :: from_ptr ( result . normalized_query ) } ; Ok ( n . to_string_lossy ( ) . to_string ( ) ) } ; unsafe { pg_query_free_normalize_result ( result ) } ; normalized_query }
Normalizes the given SQL statement, returning a parametized version.
Normalizes the given SQL statement returning a parametized version .
statement
&str
statement
&str
example
```rust
let result = pg_query::normalize("SELECT * FROM contacts WHERE name='Paul'");
assert!(result.is_ok());
let result = result.unwrap();
assert_eq!(result, "SELECT * FROM contacts WHERE name=$1");
```
` ` ` rust let result = pg_query :: normalize ( " SELECT * FROM contacts WHERE name = ' Paul ' " ) ; assert! ( result . is_ok () ) ; let result = result . unwrap () ; assert_eq! ( result " SELECT * FROM contacts WHERE name = $1 " ) ; ` ` `