Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Bugs in iif and getDate Functions in functionsfactory.ts #9674

Closed
pistillo opened this issue Apr 2, 2025 · 0 comments
Closed

Fix Bugs in iif and getDate Functions in functionsfactory.ts #9674

pistillo opened this issue Apr 2, 2025 · 0 comments
Assignees
Labels
user issue An issue or bug reported by users

Comments

@pistillo
Copy link

pistillo commented Apr 2, 2025

https://github.com/surveyjs/survey-library/blob/ddb1b9d479c93351aa6e9ee9cbff3d5b3c59dde4/packages/survey-core/src/functionsfactory.ts#L232C1-L243C55

Hi,

I have identified a couple of bugs in the iif and getDate functions defined in the file packages/survey-core/src/functionsfactory.ts. Below are the details:

1. iif Function

  • Bug: The condition if (!params && params.length !== 3) is incorrect. It should be if (!params || params.length !== 3) to correctly handle cases where params is null or undefined.
  • Current Code:
    function iif(params: any[]): any {
      if (!params && params.length !== 3) return "";
      return params[0] ? params[1] : params[2];
    }
  • Corrected Code:
    function iif(params: any[]): any {
      if (!params || params.length !== 3) return "";
      return params[0] ? params[1] : params[2];
    }

2. getDate Function

  • Bug: The condition if (!params && params.length < 1) is incorrect. It should be if (!params || params.length < 1) to correctly handle cases where params is null or undefined.
  • Current Code:
    function getDate(params: any[]): any {
      if (!params && params.length < 1) return null;
      if (!params[0]) return null;
      return createDate("function-getDate", params[0]);
    }
  • Corrected Code:
    function getDate(params: any[]): any {
      if (!params || params.length < 1) return null;
      if (!params[0]) return null;
      return createDate("function-getDate", params[0]);
    }
@JaneSjs JaneSjs added the user issue An issue or bug reported by users label Apr 2, 2025
@tsv2013 tsv2013 closed this as completed in 2f4d06a Apr 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
user issue An issue or bug reported by users
Projects
None yet
Development

No branches or pull requests

3 participants