title: Calling a string interpolator on a variable in Scala
body: <p>I am writing some database query helper methods for my classes in Scala.</p>
  
  <p>This <code>select</code> method is intended to pluck certain columns from the Product table, specified as a comma-seperated list (String) of the desired columns.</p>
  
  <p>I want to be able to call it like this: <code>Product.select("id, title")</code></p>
  
  <p>The following code does not work:</p>
  
  <pre><code>  def select(columns: String) = { DB.readOnly{ implicit session =&gt;
      sql"select ${columns} from $sqlTable limit 1000".map(row =&gt; Product(row)).list.apply()
    }}
  </code></pre>
  
  <p>But this code (for illustration purposes only) does</p>
  
  <pre><code>  def select(columns: String) = { DB.readOnly{ implicit session =&gt;
      var x = sqls"id, title, description, available_online"
      sql"select ${x} from $sqlTable limit 1000".map(row =&gt; Product(row)).list.apply()
    }}
  </code></pre>
  
  <p>Now, obviously I don't want to hard code columns into the method, but i want to do this with the <code>columns</code> parameter string (I hope you catch my drift). How can I apply the <code>sqls</code> interpolator on the columns string?</p>
  
  <p>It would be something like <code>var x = sqls(columns)</code></p>
  
  <p><a href="http://scalikejdbc.org/documentation/sql-interpolation.html" rel="nofollow">Here</a> you can find more info on the <code>sqls</code> and <code>sql</code> interpolators</p>
  
  <p>Please comment if you require more information and I'd appreciate your feedback.</p>