Skip to content

v3.0.1

Compare
Choose a tag to compare
@TimelordUK TimelordUK released this 20 Dec 17:49
· 200 commits to master since this release

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