Skip to content

feat: add support for query attributes - #4223

Merged
sidorares merged 6 commits into
masterfrom
query_attributes
Apr 9, 2026
Merged

sidorares merged 6 commits into
masterfrom
query_attributes

Conversation

@sidorares

Copy link
Copy Markdown
Owner

closes #4218

API examples:

// Send query attributes alongside a text query
const [rows] = await connection.query({
  sql: `SELECT
    mysql_query_attribute_string('trace_id') AS trace_id,
    mysql_query_attribute_string('attempt') AS attempt`,
  attributes: {
    trace_id: 'req-abc-123',
    attempt: 3
  }
});
// rows[0].trace_id === 'req-abc-123'
// rows[0].attempt  === '3'


// Attributes work alongside bind parameters
const [rows] = await connection.execute({
  sql: 'SELECT ? AS value, mysql_query_attribute_string(\'tag\') AS tag',
  values: [42],
  attributes: { tag: 'prepared-stmt' }
});
// rows[0].value === 42
// rows[0].tag   === 'prepared-stmt'

@codecov

codecov Bot commented Apr 9, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.85408% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.69%. Comparing base (3f1ca9f) to head (2bdc12a).
⚠️ Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
lib/packets/query.js 95.12% 4 Missing ⚠️
lib/packets/encode_parameter.js 98.55% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4223      +/-   ##
==========================================
+ Coverage   90.64%   90.69%   +0.04%     
==========================================
  Files          86       87       +1     
  Lines       14245    14363     +118     
  Branches     1798     1822      +24     
==========================================
+ Hits        12913    13027     +114     
- Misses       1332     1336       +4     
Flag Coverage Δ
compression-0 89.96% <97.85%> (+0.05%) ⬆️
compression-1 90.67% <97.85%> (+0.04%) ⬆️
static-parser-0 88.40% <97.85%> (+0.06%) ⬆️
static-parser-1 89.12% <97.85%> (+0.06%) ⬆️
tls-0 90.13% <97.85%> (+0.05%) ⬆️
tls-1 90.47% <97.85%> (+0.05%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@sidorares
sidorares merged commit d732f78 into master Apr 9, 2026
90 checks passed
mdierolf pushed a commit to CloudQuote/node-mysql2 that referenced this pull request May 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for query attributes

1 participant