Skip to content

Commit

Permalink
(pgsql) add test for $$ quoting existing behavior
Browse files Browse the repository at this point in the history
- even if that existing behavior is questionable
- the ending span should really close before the $$, not after

Fixing this would involve delving into the sublanguage behavior and I'm
not sure we have time to tackle that right this moment.
  • Loading branch information
joshgoebel committed Apr 27, 2020
1 parent 07450a6 commit 629de19
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
9 changes: 9 additions & 0 deletions test/markup/pgsql/dollar_strings.expect.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<span class="hljs-keyword">CREATE</span> <span class="hljs-keyword">OR REPLACE</span> <span class="hljs-keyword">FUNCTION</span> hello_world(param_your_name <span class="hljs-type">text</span>)
<span class="hljs-keyword">RETURNS</span> <span class="hljs-type">text</span> <span class="hljs-keyword">AS</span>
$$<span class="ruby">
SELECT <span class="hljs-string">'Hello world. My name is '</span> <span class="hljs-params">||</span> param_your_name <span class="hljs-params">||</span> <span class="hljs-string">'.'</span>;
$$</span>
<span class="hljs-keyword">language</span> <span class="hljs-keyword">sql</span> <span class="hljs-keyword">STRICT</span>;

<span class="hljs-keyword">SELECT</span> sql_expression($sql$<span class="ruby">SELECT hello_world($phrase$Regina<span class="hljs-string">'s elephant'</span>s dog$phrase$)
<span class="hljs-params">||</span> $phrase$ I made a cat<span class="hljs-string">'s meow today.$phrase$ $sql$</span></span>);
9 changes: 9 additions & 0 deletions test/markup/pgsql/dollar_strings.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
CREATE OR REPLACE FUNCTION hello_world(param_your_name text)
RETURNS text AS
$$
SELECT 'Hello world. My name is ' || param_your_name || '.';
$$
language sql STRICT;

SELECT sql_expression($sql$SELECT hello_world($phrase$Regina's elephant's dog$phrase$)
|| $phrase$ I made a cat's meow today.$phrase$ $sql$);

0 comments on commit 629de19

Please sign in to comment.