title: Sequelize raw query update array of objects as replacements
body: <p>I am using sequelize (postgres) and I need to properly escape a query like this:</p>
  <pre class="lang-sql prettyprint-override"><code>`
         UPDATE &quot;Pets&quot;
         SET &quot;name&quot; = CASE LOWER(&quot;name&quot;)
           ${input.pets
              .map((pet) =&gt; `WHEN '${pet.name.toLowerCase()}' THEN '${pet.newName}'`)
              .join('\n')}
            ELSE &quot;name&quot;
            END
          WHERE LOWER(&quot;name&quot;) IN(${input.pets
            .map((pet) =&gt; `'${pet.name.toLowerCase()}'`)
            .join(',')});
  `
  </code></pre>
  <p>Sample <code>input.pets</code>:</p>
  <pre><code>[{ name: &quot;rocky&quot;, newName: &quot;leo&quot; }]
  </code></pre>
  <p>Does anyone have an idea how to achieve this with replacements?</p>
  <p>I have found a thread on github which suggested something like this:</p>
  <pre class="lang-sql prettyprint-override"><code>let data = [ [ 252456, 1, 55, '0' ],
  [ 357083, 1, 56, '0' ],
  [ 316493, 1, 57, '0' ] ];
  
  db.query(
    `INSERT INTO product (a, b) VALUES ${data.map(a =&gt; '(?)').join(',')};`,
    {
       replacements: data,
       type: Sequelize.QueryTypes.INSERT
    }
  );
  </code></pre>
  <p>However, a 2d array is being used here not an array of objects. Is there a way to access individual properties from the array? When I try something like this</p>
  <pre class="lang-sql prettyprint-override"><code>`
         UPDATE &quot;Pets&quot;
         SET &quot;name&quot; = CASE LOWER(&quot;name&quot;)
           ${input.pets
              .map((_pet) =&gt; `WHEN ? THEN ?`)
              .join('\n')}
            ELSE &quot;name&quot;
            END
          WHERE LOWER(&quot;name&quot;) IN(${input.pets
            .map((_pet) =&gt; `?`)
            .join(',')});
  `,
      { type: QueryTypes.UPDATE, replacements: input.pets },
  </code></pre>
  <p>The first <code>?</code> turns out to be the whole object. Is there a way to access it's properties?
  I also tried transforming <code>input.pets</code> into a 2d array but still couldn't get it to work as in example with insert above.</p>
  <p>In advance thanks for your time</p>