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

Adjust "null" to expected behavior #521

Merged
merged 2 commits into from
Mar 8, 2018
Merged

Adjust "null" to expected behavior #521

merged 2 commits into from
Mar 8, 2018

Conversation

kalzoo
Copy link
Contributor

@kalzoo kalzoo commented Dec 30, 2017

Add "not" to ensure that when null is True (making None or '' distinct from False) that the default placeholder (--) is rendered

Add "not" to ensure that when null is True (making ` None or '' ` distinct from False) that the default placeholder (--) is rendered
@jieter
Copy link
Owner

jieter commented Dec 30, 2017

@kalzoo your change make 4 tests fail. Can you have a look at that?

@kalzoo
Copy link
Contributor Author

kalzoo commented Dec 30, 2017

@jieter, all four appear to assert the behavior that I believe is unexpected. I think it's just a semantic thing, but I would expect:

null=False  # to mean that null is *not* a distinct value
null=True  # to mean that null is a distinct value from true and false, 
                  # consistent with how the Django ORM uses it.

However, the opposite expectation is reflected in your tests, for example (tests/columns/test_booleancolumn.py:44):

    def test_treat_none_different_from_false(self):
        class Table(tables.Table):
            col = tables.BooleanColumn(null=False, default='---')

        table = Table([{'col': None}])
        assert table.rows[0].get_cell('col') == '---'

In my mind, "none different than false" should mean null=True rather than False.

Edit re: ORM

@jieter
Copy link
Owner

jieter commented Jan 3, 2018

@kalzoo thanks for fixing the tests, however, this is a breaking change and this PR provides no deprecation path.

Since this is just an issue of expectation, can we maybe also adjust the documentation (docstring) to make sure future expectations are correctly created?

@kalzoo
Copy link
Contributor Author

kalzoo commented Jan 3, 2018

True. Seemed low-impact since it won't cause exceptions, only a minor difference in output.

As a new user to django, this change is more intuitive to me, especially since it would make null usage consistent with django ORM/models. But that may not be the case for longer-time users, so it's just up to your discretion.

In any case, the library's great to have, thanks for your work in maintaining it.

@jieter
Copy link
Owner

jieter commented Jan 5, 2018

Thanks for your thoughts, I think I'll take this into django-tables2==2.0, refs #526

@jieter jieter changed the base branch from master to two March 8, 2018 15:03
@jieter jieter merged commit 82d5acb into jieter:two Mar 8, 2018
jieter pushed a commit that referenced this pull request Mar 12, 2018
* Adjust "null" to expected behavior

Add "not" to ensure that when null is True (making ` None or '' ` distinct from False) that the default placeholder (--) is rendered
jieter pushed a commit that referenced this pull request Mar 12, 2018
* Adjust "null" to expected behavior

Add "not" to ensure that when null is True (making ` None or '' ` distinct from False) that the default placeholder (--) is rendered
jieter pushed a commit that referenced this pull request Mar 12, 2018
* Adjust "null" to expected behavior

Add "not" to ensure that when null is True (making ` None or '' ` distinct from False) that the default placeholder (--) is rendered
jieter pushed a commit that referenced this pull request Mar 16, 2018
* Adjust "null" to expected behavior

Add "not" to ensure that when null is True (making ` None or '' ` distinct from False) that the default placeholder (--) is rendered
jieter pushed a commit that referenced this pull request Mar 19, 2018
* Adjust "null" to expected behavior

Add "not" to ensure that when null is True (making ` None or '' ` distinct from False) that the default placeholder (--) is rendered
jieter pushed a commit that referenced this pull request Mar 26, 2018
* Adjust "null" to expected behavior

Add "not" to ensure that when null is True (making ` None or '' ` distinct from False) that the default placeholder (--) is rendered
jieter pushed a commit that referenced this pull request Apr 10, 2018
* Adjust "null" to expected behavior

Add "not" to ensure that when null is True (making ` None or '' ` distinct from False) that the default placeholder (--) is rendered
jieter pushed a commit that referenced this pull request Apr 10, 2018
* Adjust "null" to expected behavior

Add "not" to ensure that when null is True (making ` None or '' ` distinct from False) that the default placeholder (--) is rendered
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.

2 participants