Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>There are pieces to this answer that helped me get what I needed (easy multi-line concatenation WITHOUT extra whitespace), but since none of the actual answers had it, I'm compiling them here:</p> <pre><code>str = 'this is a multi-line string'\ ' using implicit concatenation'\ ' to prevent spare \n\'s' =&gt; "this is a multi-line string using implicit concatenation to eliminate spare \\n's" </code></pre> <p>As a bonus, here's a version using funny HEREDOC syntax (via <a href="http://graysoftinc.com/ruby-voodoo/working-with-multiline-strings" rel="noreferrer">this link</a>):</p> <pre><code>p &lt;&lt;END_SQL.gsub(/\s+/, " ").strip SELECT * FROM users ORDER BY users.id DESC END_SQL # &gt;&gt; "SELECT * FROM users ORDER BY users.id DESC" </code></pre> <p>The latter would mostly be for situations that required more flexibility in the processing. I personally don't like it, it puts the processing in a weird place w.r.t. the string (i.e., in front of it, but using instance methods that usually come afterward), but it's there. Note that if you are indenting the last <code>END_SQL</code> identifier (which is common, since this is probably inside a function or module), you will need to use the hyphenated syntax (that is, <code>p &lt;&lt;-END_SQL</code> instead of <code>p &lt;&lt;END_SQL</code>). Otherwise, the indenting whitespace causes the identifier to be interpreted as a continuation of the string.</p> <p>This doesn't save much typing, but it looks nicer than using + signs, to me.</p> <p>EDIT: Adding one more:</p> <pre><code>p %{ SELECT * FROM users ORDER BY users.id DESC }.gsub(/\s+/, " ").strip # &gt;&gt; "SELECT * FROM users ORDER BY users.id DESC" </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload