From f0e2afd6fd562e0b29b663cea35cb28242eff4ed Mon Sep 17 00:00:00 2001 From: dnewsom Date: Wed, 9 Feb 2022 08:52:50 -0700 Subject: [PATCH 1/5] Allow connectAttributes through URI config --- lib/connection_config.js | 10 ++++++++++ test/unit/connection/test-connection_config.js | 12 ++++++++++++ 2 files changed, 22 insertions(+) diff --git a/lib/connection_config.js b/lib/connection_config.js index 269dc3ef74..f250c5b38c 100644 --- a/lib/connection_config.js +++ b/lib/connection_config.js @@ -258,6 +258,16 @@ class ConnectionConfig { password: parsedUrl.password }; parsedUrl.searchParams.forEach((value, key) => { + if (key === 'connectAttributes') { + options[key] = value + .split(',') + .map(x => x.split(':').map(y => y.trim())) + .reduce((a, x) => { + a[x[0]] = x[1]; + return a; + }, {}); + return; + } try { // Try to parse this as a JSON expression first options[key] = JSON.parse(value); diff --git a/test/unit/connection/test-connection_config.js b/test/unit/connection/test-connection_config.js index 0e1c0b1ca6..93a5f1316e 100644 --- a/test/unit/connection/test-connection_config.js +++ b/test/unit/connection/test-connection_config.js @@ -49,3 +49,15 @@ assert.strictEqual( ).password, 'pass!%40$%%5E&*()%5Cword%3A' ); + +assert.deepEqual( + ConnectionConfig.parseUrl( + String.raw`mysql://localhost/database?connectAttributes=program_name:testProg,second_attr:example` + ).connectAttributes, + (new ConnectionConfig({ + connectAttributes: { + program_name: 'testProg', + second_attr: 'example' + } + })).connectAttributes +); From bebed0d4ca68778c8eb44489be856ccc595cbbf4 Mon Sep 17 00:00:00 2001 From: dnewsom Date: Sun, 13 Feb 2022 23:24:34 -0700 Subject: [PATCH 2/5] Define UTC timezone and enforce date format --- test/integration/connection/test-execute-bind-date.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/test/integration/connection/test-execute-bind-date.js b/test/integration/connection/test-execute-bind-date.js index d98e58ce5b..7d1ea2ab17 100644 --- a/test/integration/connection/test-execute-bind-date.js +++ b/test/integration/connection/test-execute-bind-date.js @@ -1,5 +1,7 @@ 'use strict'; +process.env.TZ = 'UTC'; + const common = require('../../common'); const connection = common.createConnection(); const assert = require('assert'); @@ -7,7 +9,8 @@ const assert = require('assert'); const date = new Date(2018, 2, 10, 15, 12, 34, 1234); let rows; -connection.execute('SELECT ? AS result', [date], (err, _rows) => { +connection.execute(`SET @@session.time_zone = '+00:00'`); +connection.execute(`SELECT DATE_FORMAT(?, '%Y-%m-%dT%H:%i:%sZ') AS result`, [date], (err, _rows) => { if (err) { throw err; } @@ -16,5 +19,5 @@ connection.execute('SELECT ? AS result', [date], (err, _rows) => { }); process.on('exit', () => { - assert.deepEqual(rows, [{ result: date }]); + assert.deepEqual(rows, [{ result: date.toISOString().replace('.234Z', 'Z') }]); }); From 5bb72d657986a356b8be7553423f553301b0d590 Mon Sep 17 00:00:00 2001 From: dnewsom Date: Sun, 20 Feb 2022 20:04:24 -0700 Subject: [PATCH 3/5] Address config around inaccessible test data --- .github/workflows/ci-linux.yml | 51 ++-------------------------------- 1 file changed, 2 insertions(+), 49 deletions(-) diff --git a/.github/workflows/ci-linux.yml b/.github/workflows/ci-linux.yml index 5186c8297c..7181db7b9f 100644 --- a/.github/workflows/ci-linux.yml +++ b/.github/workflows/ci-linux.yml @@ -13,18 +13,7 @@ env: MYSQL_DATABASE: test jobs: - cleanup: - runs-on: ubuntu-latest - steps: - - name: Delete artifacts - uses: jimschubert/delete-artifacts-action@v1 - with: - log_level: 'debug' - min_bytes: '0' - pattern: '\.xml' - tests-linux: - needs: [ cleanup ] runs-on: ubuntu-latest strategy: fail-fast: false @@ -77,46 +66,10 @@ jobs: path: ~/.npm key: npm-${{ hashFiles('package-lock.json') }} restore-keys: npm- - + - name: Install npm dependencies run: npm ci - name: Wait mysql server is ready run: node tools/wait-up.js - - name: Run tests - run: FILTER=${{matrix.filter}} MYSQL_USE_TLS=${{ matrix.use-tls }} MYSQL_USE_COMPRESSION=${{ matrix.use-compression }} npm run coverage-test - - - run: echo "coverage-artifact-name=`echo -n "${{github.run_id}}-${{ matrix.node-version }}-${{ matrix.mysql-version }}-${{matrix.use-tls}}-${{matrix.use-compression}}" | shasum | cut -d " " -f 1`" >> $GITHUB_ENV - - uses: actions/upload-artifact@v2 - with: - name: coverage-${{env.coverage-artifact-name}} - path: coverage/cobertura-coverage.xml - - coverage: - needs: [ tests-linux ] - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Restore coverage - uses: actions/download-artifact@v2 - with: - path: coverage - - - name: get list of coverage files - run: echo "coverage-files=`find coverage | grep xml | paste -s -d\; -`" >> $GITHUB_ENV - - - name: ReportGenerator - uses: danielpalme/ReportGenerator-GitHub-Action@4.8.12 - with: - reports: "${{ env.coverage-files }}" - targetdir: '.' - reporttypes: 'Cobertura' - - - name: Debug - run: cat Cobertura.xml - - - name: Display coverage - uses: ewjoachim/coverage-comment-action@v1 - with: - COVERAGE_FILE: "Cobertura.xml" - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: FILTER=${{matrix.filter}} MYSQL_USE_TLS=${{ matrix.use-tls }} MYSQL_USE_COMPRESSION=${{ matrix.use-compression }} npm test From ed28634be4d6202b1aaa845cd111692cacf0ef20 Mon Sep 17 00:00:00 2001 From: Dave Date: Tue, 6 Dec 2022 10:47:47 -0700 Subject: [PATCH 4/5] Update ci-linux.yml --- .github/workflows/ci-linux.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci-linux.yml b/.github/workflows/ci-linux.yml index 3ba4fe58e0..eb5094bac0 100644 --- a/.github/workflows/ci-linux.yml +++ b/.github/workflows/ci-linux.yml @@ -77,7 +77,7 @@ jobs: path: ~/.npm key: npm-${{ hashFiles('package-lock.json') }} restore-keys: npm- - + - name: Install npm dependencies run: npm ci - name: Wait mysql server is ready @@ -91,7 +91,7 @@ jobs: with: name: coverage-${{env.coverage-artifact-name}} path: coverage/cobertura-coverage.xml - + coverage: permissions: write-all needs: [ tests-linux ] @@ -105,7 +105,7 @@ jobs: - name: get list of coverage files run: echo "coverage-files=`find coverage | grep xml | paste -s -d\; -`" >> $GITHUB_ENV - + - name: ReportGenerator uses: danielpalme/ReportGenerator-GitHub-Action@4.8.12 with: From b837b82e009dc6e6dd1cdbba0f5bec67b11497a8 Mon Sep 17 00:00:00 2001 From: Dave Date: Tue, 6 Dec 2022 10:48:15 -0700 Subject: [PATCH 5/5] Update ci-linux.yml --- .github/workflows/ci-linux.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-linux.yml b/.github/workflows/ci-linux.yml index eb5094bac0..b7cf117052 100644 --- a/.github/workflows/ci-linux.yml +++ b/.github/workflows/ci-linux.yml @@ -86,7 +86,7 @@ jobs: - name: Run tests run: FILTER=${{matrix.filter}} MYSQL_USE_TLS=${{ matrix.use-tls }} MYSQL_USE_COMPRESSION=${{ matrix.use-compression }} npm run coverage-test - - run: echo "coverage-artifact-name=`echo -n "${{github.run_id}}-${{ matrix.node-version }}-${{ matrix.mysql-version }}-${{matrix.use-tls}}-${{matrix.use-compression}}" | shasum | cut -d " " -f 1`" >> $GITHUB_ENV + - run: echo "coverage-artifact-name=`echo -n "${{github.run_id}}-${{ matrix.node-version }}-${{ matrix.mysql-version }}-${{matrix.use-tls}}-${{matrix.use-compression}}" | shasum | cut -d " " -f 1`" >> $GITHUB_ENV - uses: actions/upload-artifact@v2 with: name: coverage-${{env.coverage-artifact-name}}