[−][src]Function formation::format::format
pub fn format(sql: &str, check: bool, max_width: usize) -> Result<Vec<String>>
Formats a given SQL string in accordance with the given maximum width.
Each statement parsed is formatted separately. The result is a Vec<String>
where each item
represents a formatted statement of the original sql_string
input.
Errors
Returns a FormaError::InvalidInput
if the parser cannot parse the provided input.
If check
is true
, will return a FormaError::WouldFormat
if the provided input would be
formatted.
Example
use formation::format; let sql = "SELECT * FROM users;"; assert_eq!( format(sql, false, 100).unwrap(), vec!["select * from users;\n".to_owned()] );