Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1043,6 +1043,50 @@ mod tests {
assert_eq!(format(input, &QueryParams::None, &options), output);
}

#[test]
fn it_does_not_indent_next_statement_when_max_inline_arguments_is_some_nat() {
let args = [None, Some(0), Some(999)];

for arg in args {
let input = indoc!(
"
DROP INDEX IF EXISTS idx_a;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lines_between_queries:1 would add just a single new line, probably we should document it better or change its name.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I didn’t understand. Could you explain it in more detail?

DROP INDEX IF EXISTS idx_b;
"
);
let options = FormatOptions {
max_inline_arguments: arg,
..Default::default()
};
let expected = indoc!(
"
DROP INDEX IF EXISTS idx_a;

DROP INDEX IF EXISTS idx_b;
"
);

assert_eq!(format(input, &QueryParams::None, &options), expected);

let input = indoc!(
r#"
-- comment
DROP TABLE IF EXISTS "public"."table_name";
"#
);

let expected = indoc!(
r#"
-- comment
DROP TABLE IF EXISTS "public"."table_name";
"#
);

assert_eq!(format(input, &QueryParams::None, &options), expected);
}
}

#[test]
fn it_formats_incomplete_query() {
let input = "SELECT count(";
Expand Down
Loading