Skip to content

Conversation

jnunemaker
Copy link
Contributor

This is a particularly subtle and hard to catch bug. ensure when used at the method definition level runs on every method call regardless of on early return. This means that when using :force_timezone and calling results more than once, the default_timezone was getting set to nil, because the second invocation would early return, not set the zone variable and thus set default_timezone to nil in the ensure block.

ensure at the method level runs on every method call, even early returns
like the return self if sql.blank? check.

This means that timezone was being set to nil sometimes if
force_timezone was used and the sql was blank (early return). This fixes
that bug.
@jnunemaker jnunemaker self-assigned this Sep 20, 2017
@jnunemaker jnunemaker requested a review from miguelff September 20, 2017 14:40
Copy link
Contributor

@miguelff miguelff left a comment

Choose a reason for hiding this comment

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

:shipit:

@jnunemaker jnunemaker merged commit 0bf11a5 into master Sep 20, 2017
@jnunemaker jnunemaker deleted the scope-ensures branch September 20, 2017 14:42
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