title: Slonik dynamic insert query via sql tag
body: <p>Via <a href="https://github.com/gajus/slonik" rel="nofollow noreferrer">Slonik</a> I try to create a sql statement in a dynamic way. I have a list of keys I want to use for my insert statement and to create a list of values.</p>
  
  <p>This is an example of my setup. Though the definition of my insert columns always fails.</p>
  
  <pre><code>  const keys = [
      'type',
      'substance_group',
      'substance',
      'unit',
      'zone_id',
      'zone',
      'sector',
      'sub_sector',
      'sum_bruto',
      'sum_netto',
    ];
    const emissionValues = values&lt;string&gt;(pick(emission, keys));
  
    //  (type, substance_group, substance, unit, zone_id, zone, sector, sub_sector, sum_bruto, sum_netto)
    const query = sql`
      INSERT INTO api.emissions
      (${sql.array(keys, 'text')})
       VALUES (${emissionValues.join(',')})
    `;
  </code></pre>
  
  <p>I tried these forms:</p>
  
  <ul>
  <li><code>${sql.array(keys, 'text')}</code></li>
  <li><code>${sql.join(keys, sql</code>, <code>)}</code></li>
  <li>or plain <code>${keys.join(',')</code></li>
  </ul>
  
  <p>But none are allowed by the sql query builder tag.</p>