Looks like we can't reproduce the issue or there's a problem in the test case provided.
  1. #1
    Sencha Premium Member
    Join Date
    Jul 2012
    Posts
    64
    Vote Rating
    6
    jim@carroll.net is on a distinguished road

      0  

    Default BUG: Ext.data.Types BOOL is casesensitive

    BUG: Ext.data.Types BOOL is casesensitive


    Models that include 'boolean' fields are either required to provide all lowercase boolean strings OR to write a convert() function for every field that uses boolean in their Model declarations.

    Here's the relevant snippet from Ext.data.Types

    Code:
    BOOL: {
        convert: function(v) {
            if (this.useNull && (v === undefined || v === null || v === '')) {
                return null;
            }
            return v === true || v === 'true' || v == 1;
        },
        sortType: st.none,
        type: 'bool'

    I think it would be more intuitive if it did more like:

    Code:
    BOOL: {
        convert: function(v) {
            if (this.useNull && (v === undefined || v === null || v === '')) {
                return null;
            }
            return Boolean(v);
        },
        sortType: st.none,
        type: 'bool'
    No?

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,004
    Vote Rating
    846
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    Boolean(v) won't work because this would return true:

    Code:
    Boolean('I should be false')
    Now the v === 'true' could be:

    Code:
    /true/i.test(v)
    And that would be case-insensitive
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha Premium Member
    Join Date
    Jul 2012
    Posts
    64
    Vote Rating
    6
    jim@carroll.net is on a distinguished road

      0  

    Default


    You're right (of course)

    But the fact that the current incarnation is case sensitive makes this a bit cumerbsome. For example, we have a model associated with an Ajax proxy. The server in this case is returning 'True' for its booleans. It means everywhere we use 'boolean' in our extjs model's, we need to add a covert() method for each individual field that coerces to lowercase.

    Of course, we could probably create our own Ext.type.Type for something like CSBOOL -- but we use Sencha Architect for our coding activity -- and I'm not sure if we'd be able to refer to this custom type from SA.

    It seems to me that it would make syntactic sense to modify the base type, no?

  4. #4
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    16,900
    Vote Rating
    623
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    This isn't a bug, the docs are clear on what the bool type will convert automatically. The overhead of doing a case insensitive comparison isn't worth it for the small use case, especially since you can create your own types quite easily.
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

Thread Participants: 2