title: Groovy sql.rows returns org.postgresql.util.PSQLException: No hstore extension installed
body: <p>I am using Groovy Sql in Grails with named parameters to get results from a Postgres DB. My statement is generated dynamically, i.e. concatenated to become the final statement, with the params being added to a map as I go along.</p>
  
  <pre><code>sqlWhere += " AND bar = :namedParam1"
  paramsMap.namedParam1 = "blah"
  </code></pre>
  
  <p>For readability, I am using the groovy string syntax which allows me to write my sql statement over multiple lines, like this: </p>
  
  <pre><code>sql = """
        SELECT *
        FROM foo
        WHERE 1=1
        ${sqlWhere}
        """
  </code></pre>
  
  <p>The expression is evaluated as a string containing the linebreaks as \n:</p>
  
  <pre><code>SELECT *\n ...
  </code></pre>
  
  <p>This is not a problem when I pass params like this</p>
  
  <pre><code>results = sql.rows(sqlString, paramsMap)
  </code></pre>
  
  <p>but it does become one if paramsMap is empty (which happens since <code>AND bar = :namedParam1</code> is not always concatenated into the query). I then get an error </p>
  
  <pre><code>org.postgresql.util.PSQLException: No hstore extension installed  
  </code></pre>
  
  <p>which does not really seem to relate to the true nature of the problem. I have for now fixed this with an if...else</p>
  
  <pre><code>if (sqlQuery.params.size() &gt; 0) {
      results = sql.rows(sqlString, paramsMap)
  } else {
      results = sql.rows(sqlString.replace('\n',' '))
  }
  </code></pre>
  
  <p>But this seems a bit weird (especially since it does not work if I use the replace in the if-branch as well).</p>
  
  <p>My question is: why do I really get this error message and is there a better way to prevent it from occuring?</p>