[CONJS-120] Permit values in SQL object to permits compatibility with mysql/mysql2 Created: 2020-02-03  Updated: 2020-02-03  Resolved: 2020-02-03

Status: Closed
Project: MariaDB Connector/node.js
Component/s: API
Affects Version/s: None
Fix Version/s: 2.2.0

Type: New Feature Priority: Major
Reporter: Diego Dupin Assignee: Diego Dupin
Resolution: Fixed Votes: 0
Labels: None


 Description   

Permits passing values in sql object to permit compatibility with mysql/mysql2, permitting compatibility with sql-template-strings at the same time.

standard API is using :

connection.query('SELECT ? as a', ['myValue'])
   .then(rows => {
      console.log(rows); //[ { 'a': myValue' }, meta: [ ... ] ]
  })
  .catch(...)

or sql object:

connection.query({sql:'SELECT ? as a'}, ['myValue'])
   .then(rows => {
      console.log(rows); //[ { 'a': myValue' }, meta: [ ... ] ]
  })
  .catch(...)

Using sql object, value can be given as 'values' entry:

connection.query({sql:'SELECT ? as a', value: ['myValue']})
   .then(rows => {
      console.log(rows); //[ { 'a': myValue' }, meta: [ ... ] ]
  })
  .catch(...)


Generated at Thu Feb 08 03:22:54 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.