Skip to content

Improves SQL parameter handling and query safety#117

Open
precious-ndamati-stream4Tech wants to merge 1 commit intomainfrom
dev/precious/fix-stack-size-error
Open

Improves SQL parameter handling and query safety#117
precious-ndamati-stream4Tech wants to merge 1 commit intomainfrom
dev/precious/fix-stack-size-error

Conversation

@precious-ndamati-stream4Tech
Copy link
Collaborator

Refactors parameter processing for better handling of nested names, null values, and case-insensitive logic. Enhances robustness for IN/BETWEEN operators and prevents unsafe replacements in queries. Updates package version for release.

Refactors parameter processing for better handling of nested names,
null values, and case-insensitive logic. Enhances robustness for
IN/BETWEEN operators and prevents unsafe replacements in queries.
Updates package version for release.
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors the addParameters method in lib/sql.js to improve code clarity, maintainability, and safety. The version number is bumped from 1.0.48 to 1.0.49.

Key changes:

  • Refactored the addParameters method for better readability with clearer variable names and improved code structure
  • Enhanced safety with checks to prevent infinite replacement loops
  • Consolidated conditional logic for better maintainability

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
package.json Version bump from 1.0.48 to 1.0.49
lib/sql.js Refactored addParameters method with improved variable naming, consolidated logic, and added safety checks for string replacement

const placeholder = `${this.parameterPrefix}{${shortName}}`;
const replacement = inResult.paramNames.join(', ');

if (typeof query === 'string' && !replacement.includes(placeholder) && !isBetween) {
Copy link

Copilot AI Nov 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The check '!replacement.includes(placeholder)' may not prevent all infinite replacement scenarios. If the placeholder appears in any of the generated parameter names (e.g., shortName contains '{shortName}'), this could still cause issues. Consider a more robust check or document this edge case.

Copilot uses AI. Check for mistakes.
if (props !== undefined && props !== null && typeof props === 'object') {

// Extract object-style properties
if (props && typeof props === 'object' && props !== null) {
Copy link

Copilot AI Nov 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Variable 'props' is of type date, object or regular expression, but it is compared to an expression of type null.

Suggested change
if (props && typeof props === 'object' && props !== null) {
if (props && typeof props === 'object' && props.constructor === Object) {

Copilot uses AI. Check for mistakes.
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.

1 participant

Comments