title: PostgreSQL error: column "qty" is of type integer but expression is of type text
body: <p>The query below is dynamically generated based on the number of rows that are being inserted.  For each row of data, there is an additional <code>UNION SELECT</code> statement.</p>
  
  <pre><code>INSERT INTO account_sale
  (qty, price, product_id)
  
  SELECT $1, $2, t.id
    FROM inventory_product AS t
    WHERE  t.ebay_sku = $3
  
  UNION
  
  SELECT $4, $5, t.id
    FROM inventory_product AS t
    WHERE  t.ebay_sku = $6  
  ...
  </code></pre>
  
  <p>When I try to run the query, I get the following:</p>
  
  <blockquote>
    <p>error: column "qty" is of type integer but expression is of type text</p>
  </blockquote>
  
  <p>The node.js page for this query:</p>
  
  <pre><code>module.exports = async function(orders) {
    const pool = require('./config.js');
    const client = await pool.connect();
  
    const sql = ...
    const data = [
      1, 1.50, 10, 
      2, 4.50, 11
    ];
  
    client.query(sql, data).then(res =&gt; {
    ...
  
    }).catch(err =&gt; console.log(err));
  }
  </code></pre>
  
  <p>If I remove the <code>UNION</code> from the query, like this:</p>
  
  <pre><code>INSERT INTO account_sale
  (qty, price, product_id)
  
  SELECT $1, $2, t.id
    FROM inventory_product AS t
    WHERE  t.ebay_sku = $3
  </code></pre>
  
  <p>and remove the second item from <code>data</code>, there <strong>isn't</strong> any errors.</p>
  
  <p>What am I missing here?</p>