11import dedent from "dedent-js" ;
2- import { testBigquery } from "../test_utils" ;
2+ import { testBigquery , testPlpgsql } from "../test_utils" ;
33
44describe ( "raise" , ( ) => {
55 it ( `formats RAISE statement` , async ( ) => {
@@ -13,4 +13,33 @@ describe("raise", () => {
1313 RAISE USING MESSAGE = 'Serious error!'
1414 ` ) ;
1515 } ) ;
16+
17+ it ( `formats RAISE with condition name` , async ( ) => {
18+ await testPlpgsql ( dedent `
19+ RAISE division_by_zero
20+ ` ) ;
21+ } ) ;
22+
23+ it ( `formats RAISE with SQLSTATE` , async ( ) => {
24+ await testPlpgsql ( dedent `
25+ RAISE SQLSTATE 'P0001'
26+ ` ) ;
27+ } ) ;
28+
29+ it ( `formats RAISE with level and USING clause` , async ( ) => {
30+ await testPlpgsql ( dedent `
31+ RAISE WARNING index_out_of_range
32+ USING MESSAGE = 'Index is out of range', HINT = 'Whatever'
33+ ` ) ;
34+ } ) ;
35+
36+ it ( `formats RAISE with long USING clause` , async ( ) => {
37+ await testPlpgsql ( dedent `
38+ RAISE index_out_of_range
39+ USING
40+ MESSAGE = 'Index is out of range',
41+ HINT = 'Please check the index and try again',
42+ DETAIL = 'The index you provided is 10, but the maximum allowed is 5'
43+ ` ) ;
44+ } ) ;
1645} ) ;
0 commit comments