diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index afaa6d7..dc0b60a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -16,15 +16,15 @@ jobs: - 1433:1433 strategy: matrix: - node-version: [18.x] + node-version: [20.x, 22.x] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: node-version: ${{ matrix.node-version }} - - uses: pnpm/action-setup@v2.2.2 + - uses: pnpm/action-setup@v4 with: - version: 7.12.2 + version: 9 - run: pnpm i - run: pnpm t diff --git a/src/identifier.test.ts b/src/identifier.test.ts index d77934f..d0c69da 100644 --- a/src/identifier.test.ts +++ b/src/identifier.test.ts @@ -14,6 +14,14 @@ test('json value', () => { expect(Tsql.id('fooJson->bar').toString()).toEqual('json_value(fooJson, N\'bar\')') }) +test('json query', () => { + expect(Tsql.id('fooJson~>bar').toString()).toEqual('json_query(fooJson, N\'bar\')') +}) + +test('json path exists', () => { + expect(Tsql.id('fooJson?>bar').toString()).toEqual('json_path_exists(fooJson, N\'bar\')') +}) + test('quote', () => { expect(Tsql.id('Target').toString()).toEqual('[Target]') expect(Tsql.id('foo[bar').toString()).toEqual('[foo[bar]') @@ -23,7 +31,3 @@ test('quote', () => { expect(Tsql.id('_foo').toString()).toEqual('_foo') expect(Tsql.id('1foo').toString()).toEqual('[1foo]') }) - -test('json path exists', () => { - expect(Tsql.id('fooJson?>bar').toString()).toEqual('json_path_exists(fooJson, N\'bar\')') -}) diff --git a/src/where.test.ts b/src/where.test.ts index b2613e5..30c8ff1 100644 --- a/src/where.test.ts +++ b/src/where.test.ts @@ -54,8 +54,12 @@ test('different ops', () => { }, '((a in (1, 2, 3)) and (b like N\'foo%\') and (c >= 5) and (d <= 1) and (e < 0) and (f not in (3, 5, 7)) and (g = 3) and (h <> 0) and (i !> 1) and (j !< -1) and (not ((k = 0)) or (l = 1)) and (m between 0 and 1) and (n not between 0 and 1))') }) -test('json', () => { - expect(Tsql.where({ 'payloadJson->status': 'COMPLETED' }).toString()).toEqual('(json_value(payloadJson, N\'status\') = N\'COMPLETED\')') +test('json value', () => { + expect(Tsql.where({ 'payloadJson->$.status': 'COMPLETED' }).toString()).toEqual('(json_value(payloadJson, N\'$.status\') = N\'COMPLETED\')') +}) + +test('json exists', () => { + expect(Tsql.where({ 'payloadJson?>$.status': true }).toString()).toEqual('(json_path_exists(payloadJson, N\'$.status\') = cast(1 as bit))') }) test('unique', () => {