Skip to content

Releases: TimelordUK/node-sqlserver-v8

electron v29,v30 node v22

23 Apr 21:03
485dc1a
Compare
Choose a tag to compare
description link
next js example, note cant run driver on UI thread. todo-with-nextjs_msnodesqlv8
using in typescript msnodesqlv8_ts_sample
js example typings in IDE msnodesqlv8_yarn_sample
using sequelize msnodesqlv8-sequelize
  1. release binaries for electron v29,v30 (v28 not supported) #324
  2. node v22 binaries
  3. patch PR from contributor on date parsing #318
  4. update packages to latest
  5. reworked typings to better interop with JS/TS
import sql from 'msnodesqlv8'
import Connection = MsNodeSqlV8.Connection
import ConnectionPromises = MsNodeSqlV8.ConnectionPromises
async function t() {
    const connectionString  = "Driver={ODBC Driver 17 for SQL Server};Server=(localdb)\\node;Database=scratch;Trusted_Connection=yes;"
    const con:Connection = await sql.promises.open(connectString)
    const promises:ConnectionPromises  = con.promises
    const res = await promises.query('select @@servername as server')
    console.log(JSON.stringify(res, null, 4))
    await con.promises.close()
}

t().then(() => {
    console.log('closed')
})
const connectionString  = "Driver={ODBC Driver 17 for SQL Server};Server=(localdb)\\node;Database=scratch;Trusted_Connection=yes;"

const sql = require('msnodesqlv8')

const query = 'SELECT top 2 * FROM syscolumns'

async function runner() {
    console.log(`using connection '${connectionString}' run query '${query}'`)
    const res = await sql.promises.query(connectionString, query)
    console.log(JSON.stringify(res, null, 4))
}

runner().then(() => {
    console.log('done.')
}).catch(e => {
    console.error(e)
})

image

v4.2.0: Merge pull request #326 from TimelordUK/electron.v29

22 Apr 17:59
485dc1a
Compare
Choose a tag to compare

4.1.2

16 Nov 22:23
667e528
Compare
Choose a tag to compare

NextJS patch

please see https://github.com/TimelordUK/todo-with-nextjs_msnodesqlv8

for a sample NextJS application using msnodesqlv8

v4.1.1

24 Sep 16:22
9a8716d
Compare
Choose a tag to compare
  1. electron v27 binaries
  2. node v21 binaries

v4.1.0

22 May 20:06
46b0c00
Compare
Choose a tag to compare

typescript users note types are now split into their own module

import { Error, PoolOptions, Query, SqlClient, QueryDescription, Pool, PoolStatusRecord } from 'msnodesqlv8/types'
const sql: SqlClient = require('msnodesqlv8')
  1. #284

proven solution for Debian, Ubuntu running node 18, 20 experiencing SEGV core dump - install from src openssl 3.2

see appveyor and tool/openssl.sh

  1. #285

tested platforms

OS Node Version ODBC Version SSL version action
Windows 10 12, 14, 16, 18, 20 17, 18 leave default
Windows 11 18, 20 18 leave default
Ubuntu 22.04.2 18, 20 17, 18 openssl 3.2 e.g. tool/openssl.sh
Ubuntu 20.04 18, 20 18 openssl 3.2 e.g. tool/openssl.sh
Ubuntu 20.04 12, 14, 16 17, 18 openssl 1.1 leave default
Lubuntu 20.04 18, 20 18 openssl 3.2 e.g. tool/openssl.sh
Debian 18, 20 17, 18 openssl 3.2 e.g tool/openssl.sh
Alpine 3.16 18 18 openssl 1.1.1t leave default
MacOS Big Sur 18, 20 18 libressl 2.8.3 leave default
  1. #287 - unicode 16 bit col names

  2. electron 25 binaries

  3. electron 26 binaries

v4.0.0

08 May 11:52
a9732a0
Compare
Choose a tag to compare
v4.0.0 Pre-release
Pre-release

typescript users note types are now split into their own module

import { Error, PoolOptions, Query, SqlClient, QueryDescription, Pool, PoolStatusRecord } from 'msnodesqlv8/types'
const sql: SqlClient = require('msnodesqlv8')
  1. #284

proven solution for Debian, Ubuntu running node 18, 20 experiencing SEGV core dump - install from src openssl 3.2

see appveyor and tool/openssl.sh

  1. #285

tested platforms

OS Node Version ODBC Version SSL version action
Windows 10 12, 14, 16, 18, 20 17, 18 leave default
Windows 11 18, 20 18 leave default
Ubuntu 22.04.2 18, 20 17, 18 openssl 3.2 e.g. tool/openssl.sh
Ubuntu 20.04 18, 20 18 openssl 3.2 e.g. tool/openssl.sh
Ubuntu 20.04 12, 14, 16 17, 18 openssl 1.1 leave default
Lubuntu 20.04 18, 20 18 openssl 3.2 e.g. tool/openssl.sh
Debian 18, 20 17, 18 openssl 3.2 e.g tool/openssl.sh
Alpine 3.16 18 18 openssl 1.1.1t leave default
MacOS Big Sur 18, 20 18 libressl 2.8.3 leave default

v3.1.0

12 Mar 17:18
Compare
Choose a tag to compare

What's Changed

  1. Bump qs from 6.5.2 to 6.5.3 by @dependabot in #269

  2. Bump json5 from 1.0.1 to 1.0.2 by @dependabot in #272

  3. allow more than 1 installed MS driver in linux and pick up latest for gyp build
    Gyp by @TimelordUK in #274

  4. missing results in sproc see #276 PR #280

  5. binaries for node v20

  6. binaries for latest electron including preview v24

  7. continued modernisation of JS into classes for better maintenance

v3.0.1

20 Dec 17:49
Compare
Choose a tag to compare

This is a release containing a lot of reworking under the covers and should hence be tested thoroughly before deployment into production systems.

the focus has mainly been on precise binding specifically for stored procedures and bound tables such that always on encryption will work with all ODBC supported types that are compatible with this feature. datetimeoffset, time(n), date, real, datetime2, numeric, binary(n), varbinary(n), decimal, nvarchar(n), char(n), bit, bigint, tinyint, smallint, int all work with table binding and procedure calls.

float via encryption works only for a single parameter value in stored proc it does not work for bulk table binding.

money types do not work with ODBC and always on encryption

when using general queries conn.query('select * from mytable', ...) there will be no change in way the driver works - the type bound in driver on a parameter is essentilly 'guessed' based on presented JS type. This works fine as the server will translate over to exact column type - this will not work with always on encryption and you will likely receive errors stating there is a type mismatch between the guess made and actual column definition.

tvp is also not supported.

new promise to cancel a query from returned Query

  it('use promise on query to cancel', async function handler () {
    const conn = env.theConnection
    const waitsql = env.waitForSql(20)
    const q = conn.query(waitsql)
    const err = await q.promises.cancel()
    assert(err.message.includes('Operation canceled'))
  })

new promise to call on a fetched procedure

    await createProc(spName)
    const msg = 'hello world'
    const proc = await env.theConnection.promises.getProc(spName)
    const res = await proc.promises.call({
      param: msg
    })

image

improved typings and JSDoc in index.d.ts - part 1 this will be continued in future releases, any contributions from TS typings experts very much welcome.

any changes must be compatible with current typescript test code

i.e. npm run build must compile

npm run build
> msnodesqlv8@3.0.0 build
> tsc


msnodesqlv8 git(master) node .\dist\samples\typescript\builder.js
IF OBJECT_ID('dbo.tmpTableBuilder', 'U') IS NOT NULL DROP TABLE dbo.tmpTableBuilder;
CREATE TABLE dbo.tmpTableBuilder ([id] int , [col_a] int NOT NULL, [col_b] varchar (100) NOT NULL, [col_c] int NOT NULL, [col_d] int NOT NULL, [col_e] varchar (100) NOT NULL)
[
    {
        "id": 0,
        "col_a": 0,
        "col_b": "str_0",
        "col_c": 1,
        "col_d": -1,
        "col_e": "str2_0"
    },
    {
        "id": 1,
        "col_a": 5,
        "col_b": "str_1",
        "col_c": 2,
        "col_d": 0,
        "col_e": "str2_1"
    },
    {
        "id": 2,
        "col_a": 10,
        "col_b": "str_2",
        "col_c": 3,
        "col_d": 1,
        "col_e": "str2_2"
    },
    {
        "id": 3,
        "col_a": 15,
        "col_b": "str_3",
        "col_c": 4,
        "col_d": 2,
        "col_e": "str2_3"
    },
    {
        "id": 4,
        "col_a": 20,
        "col_b": "str_4",
        "col_c": 5,
        "col_d": 3,
        "col_e": "str2_4"
    }
]
CREATE TYPE dbo.tmpTableBuilderType AS TABLE ([id] int , [col_a] int , [col_b] varchar (100) , [col_c] int , [col_d] int , [col_e] varchar (100) )
create or alter procedure dbo.tmpTableBuilder_tvp_inserter
    (
      @tvp dbo.tmpTableBuilderType READONLY
    )
    AS
    BEGIN
      set nocount on
      INSERT INTO dbo.tmpTableBuilder
      (
        [id],
                [col_a],
                [col_b],
                [col_c],
                [col_d],
                [col_e]
      )
      SELECT
        [id],
                [col_a],
                [col_b],
                [col_c],
                [col_d],
                [col_e]
      n FROM @tvp tvp
    END
id 0 equals true
id 1 equals true
id 2 equals true
id 3 equals true
id 4 equals true
done

#265

always on encryption now working on stored proc and bound table calls - please see tests\encrypt.js

e.g with table below

CREATE TABLE node.dbo.test_encrpted_table (
[id] int IDENTITY(1,1) NOT NULL, [field] int ENCRYPTED WITH 
     (COLUMN_ENCRYPTION_KEY = [CEK_Auto1],   
     ENCRYPTION_TYPE = Deterministic, 
    ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256'))
    const table = await conn.promises.getTable('test_encrpted_table')
    const v = 
[
  {
    field: 12345,
  },
]
    await table.promises.insert(v)
   

tables bound with numeric columns now encode correctly into ODBC rather than using doubles which had been case previously.

electron v22 binaries included

refactored table binding and stored procedures code.

Full Changelog: v3.0.0...v3.0.1

always on encryption

30 Nov 23:01
d32dd51
Compare
Choose a tag to compare

new promise to cancel a query from returned Query

  it('use promise on query to cancel', async function handler () {
    const conn = env.theConnection
    const waitsql = env.waitForSql(20)
    const q = conn.query(waitsql)
    const err = await q.promises.cancel()
    assert(err.message.includes('Operation canceled'))
  })

new promise to call on a fetched procedure

    await createProc(spName)
    const msg = 'hello world'
    const proc = await env.theConnection.promises.getProc(spName)
    const res = await proc.promises.call({
      param: msg
    })

image

improved typings and JSDoc in index.d.ts - part 1 this will be continued in future releases, any contributions from TS typings experts very much welcome.

any changes must be compatible with current typescript test code

i.e. npm run build must compile

npm run build
> msnodesqlv8@3.0.0 build
> tsc


msnodesqlv8 git(master) node .\dist\samples\typescript\builder.js
IF OBJECT_ID('dbo.tmpTableBuilder', 'U') IS NOT NULL DROP TABLE dbo.tmpTableBuilder;
CREATE TABLE dbo.tmpTableBuilder ([id] int , [col_a] int NOT NULL, [col_b] varchar (100) NOT NULL, [col_c] int NOT NULL, [col_d] int NOT NULL, [col_e] varchar (100) NOT NULL)
[
    {
        "id": 0,
        "col_a": 0,
        "col_b": "str_0",
        "col_c": 1,
        "col_d": -1,
        "col_e": "str2_0"
    },
    {
        "id": 1,
        "col_a": 5,
        "col_b": "str_1",
        "col_c": 2,
        "col_d": 0,
        "col_e": "str2_1"
    },
    {
        "id": 2,
        "col_a": 10,
        "col_b": "str_2",
        "col_c": 3,
        "col_d": 1,
        "col_e": "str2_2"
    },
    {
        "id": 3,
        "col_a": 15,
        "col_b": "str_3",
        "col_c": 4,
        "col_d": 2,
        "col_e": "str2_3"
    },
    {
        "id": 4,
        "col_a": 20,
        "col_b": "str_4",
        "col_c": 5,
        "col_d": 3,
        "col_e": "str2_4"
    }
]
CREATE TYPE dbo.tmpTableBuilderType AS TABLE ([id] int , [col_a] int , [col_b] varchar (100) , [col_c] int , [col_d] int , [col_e] varchar (100) )
create or alter procedure dbo.tmpTableBuilder_tvp_inserter
    (
      @tvp dbo.tmpTableBuilderType READONLY
    )
    AS
    BEGIN
      set nocount on
      INSERT INTO dbo.tmpTableBuilder
      (
        [id],
                [col_a],
                [col_b],
                [col_c],
                [col_d],
                [col_e]
      )
      SELECT
        [id],
                [col_a],
                [col_b],
                [col_c],
                [col_d],
                [col_e]
      n FROM @tvp tvp
    END
id 0 equals true
id 1 equals true
id 2 equals true
id 3 equals true
id 4 equals true
done

#265

always on encryption now working on stored proc and bound table calls - please see tests\encrypt.js

e.g with table below

CREATE TABLE node.dbo.test_encrpted_table (
[id] int IDENTITY(1,1) NOT NULL, [field] int ENCRYPTED WITH 
     (COLUMN_ENCRYPTION_KEY = [CEK_Auto1],   
     ENCRYPTION_TYPE = Deterministic, 
    ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256'))
    const table = await conn.promises.getTable('test_encrpted_table')
    const v = 
[
  {
    field: 12345,
  },
]
    await table.promises.insert(v)
   

electron v22 binaries included

v2.7.0

09 Oct 17:49
Compare
Choose a tag to compare
  1. Node 19 binaries.
  2. better handling of blocked long running queries #264
const timeoutSproc = `CREATE OR ALTER PROCEDURE <name>
AS
BEGIN
\tSET NOCOUNT ON;
\tSET XACT_ABORT ON;
\tWAITFOR DELAY '00:10'; -- 10 minutes
END;
`


    it('pool: sproc with timeout early terminates - check pool', async function handler () {
      const spName = 'timeoutTest'
      const size = 4
      const pool = env.pool(size)
      await pool.promises.open()
      await env.promisedCreate(spName, timeoutSproc)
      try {
        await pool.promises.callProc(spName, {}, { timeoutMs: 2000 })
        throw new Error('expected exception')
      } catch (err) {
        assert(err)
        assert(err.message.includes('Query cancelled'))
        const res = await pool.promises.query('select 1 as n')
        expect(res.first[0].n).equals(1)
      } finally {
        await pool.close()
      }
    })