[][src]Function formation::format::format

pub fn format(
    sql_string: String,
    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_string = "SELECT * FROM users;".to_owned();
assert_eq!(
    format(sql_string, false, 100).unwrap(),
    vec!["select * from users;\n".to_owned()]
);