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

Null values in query data causes a null value error. #408

Closed
weenchehawk opened this Issue Feb 18, 2018 · 1 comment

Comments

Projects
None yet
2 participants
@weenchehawk

weenchehawk commented Feb 18, 2018

If the result of a web query contains null data, for example as per nickname below;

{
 "status": true,
  "error": null,
  "data": {
    "user": [
      {
        "personid": 1,
        "familyname": "De-Flores",
        "firstname": "Nancy",
        "nickname": null,
        "birthlocation": "Somewhere Beautiful, Alabama",
      }
    ]
  }
}

A null value failure is encountered at jquery.typeahead.min.js:10:23495.

This seems to map to jquery.typeahead.js::1923

                        if (~[undefined, true].indexOf(groupFilter)) {
                            comparedDisplay = displayValue;
                            comparedDisplay = comparedDisplay.toString().toLowerCase();

                            if (this.options.accent) {
                                comparedDisplay = this.helper.removeAccent.call(
                                    this,
                                    comparedDisplay
                                );
                            }

Suggested fix is to check for null in the if ()

                        if (displayValue != null && ~[undefined, true].indexOf(groupFilter))
                        {
                            comparedDisplay = displayValue;

I patched my .min. with if(r != null && . . . and it seems to work.

Hardly a rigorous fix but there's little point in me digging about in the .js for a day - I'd still probably miss something subtle. Hope we can get a full fix soon.

@weenchehawk weenchehawk changed the title from Null values in query data cause exception. to Null values in query data causes a null value error. Feb 18, 2018

@running-coder running-coder added the Bug label Mar 30, 2018

@running-coder running-coder added this to the 2.10.5 milestone Mar 30, 2018

@running-coder

This comment has been minimized.

Owner

running-coder commented Mar 30, 2018

I've added your suggested fix and a test to cover it, let me know if that works

running-coder added a commit that referenced this issue Jul 19, 2018

Version 2.10.5
Features
- Feature #397 update data of a multiselect

Fixes
- Fix #389 Allow `onLayoutBuiltBefore` to return a custom template, wrap `<li>` inside other `<ul>` or `<div>`
- Fix #396 limitTemplate doesn't display unless emptyTemplate is defined
- Fix #408 Null values in query data causes a null value error.
- Fix #424 groupOrder array doesn't work when group is a string
- Fix #434 The item value in the onCancel function in undefined
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment