Skip to content

Commit

Permalink
Merge pull request #48 from waterlink/crystal-0.15.0
Browse files Browse the repository at this point in the history
Crystal 0.15.0
  • Loading branch information
waterlink committed Apr 2, 2016
2 parents e12e514 + 1551bd1 commit 643a9c8
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 12 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Add it to `shard.yml`:
dependencies:
active_record:
github: waterlink/active_record.cr
version: 0.3.2
version: 0.4.0
```

Additionally you would need to choose your database driver adapter. For
Expand Down Expand Up @@ -187,7 +187,7 @@ criteria("subject_id").is_not_null # [(subject_id) IS NOT NUL

Supported comparison operators: `== != > >= < <=`

Supported logic operators: `or | and & xor ^ not !`
Supported logic operators: `or | and & xor ^ not`

Supported is operators: `is_true is_not_true is_false is_not_false is_unknown is_not_unknown is_null is_not_null`

Expand Down
2 changes: 1 addition & 1 deletion shard.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: active_record
version: 0.3.2
version: 0.4.0

authors:
- Oleksii Fedorov <[email protected]>
Expand Down
10 changes: 3 additions & 7 deletions spec/sql/query_generator_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -139,21 +139,17 @@ module ActiveRecord
expected_query = Query["NOT (number < :1)", {"1" => 35}]
generate(query).should eq(expected_query)

query = !(criteria("number") < 35)
expected_query = Query["NOT (number < :1)", {"1" => 35}]
generate(query).should eq(expected_query)

query = !(criteria("number") < 35).and(criteria("other_person") == 1)
query = ((criteria("number") < 35).and(criteria("other_person") == 1)).not
expected_query = Query["NOT ((number < :1) AND (other_person = :2))",
{"1" => 35, "2" => 1}]
generate(query).should eq(expected_query)

query = (!(criteria("number") < 35)).and(criteria("other_person") == 1)
query = (criteria("number") < 35).not.and(criteria("other_person") == 1)
expected_query = Query["(NOT (number < :1)) AND (other_person = :2)",
{"1" => 35, "2" => 1}]
generate(query).should eq(expected_query)

query = (criteria("number") < 35).and(!(criteria("other_person") == 1))
query = (criteria("number") < 35).and((criteria("other_person") == 1).not)
expected_query = Query["(number < :1) AND (NOT (other_person = :2))",
{"1" => 35, "2" => 1}]
generate(query).should eq(expected_query)
Expand Down
2 changes: 0 additions & 2 deletions src/query.cr
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ module ActiveRecord
unary_op(Not)
end

alias_operation :!, :not

def is_true
unary_op(IsTrue)
end
Expand Down

0 comments on commit 643a9c8

Please sign in to comment.