Skip to content

Commit

Permalink
fix: RETURNING is not placed on a new line
Browse files Browse the repository at this point in the history
  • Loading branch information
wugeer authored and shssoichiro committed Aug 27, 2024
1 parent 78f24a6 commit 94b3c39
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1591,4 +1591,29 @@ mod tests {

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

#[test]
fn it_recognizes_returning_clause() {
let input = indoc!(
"
INSERT INTO
users (name, email)
VALUES
($1, $2) RETURNING name,
email"
);
let options = FormatOptions::default();
let expected = indoc!(
"
INSERT INTO
users (name, email)
VALUES
($1, $2)
RETURNING
name,
email"
);

assert_eq!(format(input, &QueryParams::None, options), expected);
}
}
1 change: 1 addition & 0 deletions src/tokenizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,7 @@ fn get_top_level_reserved_token(input: &str) -> IResult<&str, Token<'_>> {
terminated(tag("UPDATE"), end_of_word),
terminated(tag("VALUES"), end_of_word),
terminated(tag("WHERE"), end_of_word),
terminated(tag("RETURNING"), end_of_word),
)),
))(&uc_input);
if let Ok((_, token)) = result {
Expand Down

0 comments on commit 94b3c39

Please sign in to comment.