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

added expressions to where condition #46

Merged
merged 5 commits into from Jul 30, 2014
Merged

added expressions to where condition #46

merged 5 commits into from Jul 30, 2014

Conversation

ghost
Copy link

@ghost ghost commented Jul 29, 2014

Closes #42

Coen Wessels added 2 commits July 28, 2014 22:19
Sequel already has an option to define you condition in a code block,
like this:

```ruby
UserRepository.where{ age > 31 }
```
@ghost ghost changed the title added expressions to where condition #42 added expressions to where condition lotus/model#42 Jul 29, 2014
@ghost ghost changed the title added expressions to where condition lotus/model#42 added expressions to where condition lotus/model@42 Jul 29, 2014
@ghost ghost changed the title added expressions to where condition lotus/model@42 added expressions to where condition #42 Jul 29, 2014
@ghost ghost changed the title added expressions to where condition #42 added expressions to where condition Jul 29, 2014
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.51%) when pulling 3fe74fc on coenert:master into 1b0ee81 on lotus:master.

# # => SELECT * FROM `articles` WHERE (`publish_at` > DATE('2014-07-29'))
def where(condition=nil, &blk)
condition or blk or raise ArgumentError.new("You need to specify an condition.")
condition = blk unless condition
Copy link
Member

Choose a reason for hiding this comment

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

What if we avoid this line and do:

def where(condition=nil, &blk)
  condition = condition or blk or raise ArgumentError.new('You need to specify an condition.')
  conditions.push([:where, condition])
end

Copy link
Author

Choose a reason for hiding this comment

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

good idea. with returning self

@jodosha
Copy link
Member

jodosha commented Jul 29, 2014

@coenert Thanks for this PR, it looks good.
Please complete it, by adding the same feature to #or and #exclude too. Thanks! 👍

@ghost
Copy link
Author

ghost commented Jul 29, 2014

@jodosha thanks! i also implemented the feature for #or and #exclude.

@jodosha
Copy link
Member

jodosha commented Jul 29, 2014

@coenert that looks great! Can you please add some extra examples to all the three methods? Thanks.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.17%) when pulling 5b14a18 on coenert:master into 1b0ee81 on lotus:master.

@jodosha
Copy link
Member

jodosha commented Jul 30, 2014

@coenert Looks good, merging! 👍

jodosha added a commit that referenced this pull request Jul 30, 2014
added expressions to where condition
@jodosha jodosha merged commit 135a8a7 into hanami:master Jul 30, 2014
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.

SQL Comparison Operators
2 participants