@@ -49,7 +49,7 @@ describe('PostgreSqlFormatter', () => {
4949 ] ) ;
5050 supportsJoin ( format ) ;
5151
52- it ( 'supports $placeholders' , ( ) => {
52+ it ( 'supports $n placeholders' , ( ) => {
5353 const result = format ( 'SELECT $1, $2 FROM tbl' ) ;
5454 expect ( result ) . toBe ( dedent `
5555 SELECT
@@ -60,7 +60,7 @@ describe('PostgreSqlFormatter', () => {
6060 ` ) ;
6161 } ) ;
6262
63- it ( 'replaces $placeholders with param values' , ( ) => {
63+ it ( 'replaces $n placeholders with param values' , ( ) => {
6464 const result = format ( 'SELECT $1, $2 FROM tbl' , {
6565 params : { 1 : '"variable value"' , 2 : '"blah"' } ,
6666 } ) ;
@@ -72,4 +72,20 @@ describe('PostgreSqlFormatter', () => {
7272 tbl
7373 ` ) ;
7474 } ) ;
75+
76+ it ( 'supports :name placeholders' , ( ) => {
77+ expect ( format ( 'foo = :bar' ) ) . toBe ( 'foo = :bar' ) ;
78+ } ) ;
79+
80+ it ( 'replaces :name placeholders with param values' , ( ) => {
81+ expect (
82+ format ( `foo = :bar AND :"field" = 10 OR col = :'val'` , {
83+ params : { bar : "'Hello'" , field : 'some_col' , val : 7 } ,
84+ } )
85+ ) . toBe ( dedent `
86+ foo = 'Hello'
87+ AND some_col = 10
88+ OR col = 7
89+ ` ) ;
90+ } ) ;
7591} ) ;
0 commit comments