forked from amatsuda/everywhere
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
101 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
Copyright (c) 2011 Akira Matsuda | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining | ||
a copy of this software and associated documentation files (the | ||
"Software"), to deal in the Software without restriction, including | ||
without limitation the rights to use, copy, modify, merge, publish, | ||
distribute, sublicense, and/or sell copies of the Software, and to | ||
permit persons to whom the Software is furnished to do so, subject to | ||
the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
= Everywhere | ||
|
||
Hash condition syntax for AR query everywhere! | ||
|
||
|
||
== Features | ||
|
||
=== where + not | ||
|
||
"+Everywhere+" enables you to construct where + not query such as below using AR Hash query syntax. | ||
|
||
SELECT "users".* FROM "users" WHERE ("users"."name" != 'foo') | ||
SELECT "users".* FROM "users" WHERE ("users"."created_at" IS NOT NULL) | ||
SELECT "users".* FROM "users" WHERE ("users"."status" NOT IN ('inactive', 'deleted') | ||
|
||
|
||
== Syntaxes | ||
|
||
"+Everywhere+" supports 4 syntaxes. | ||
|
||
* hash_value | ||
Push the value into a Hash indexed by +:not+. | ||
Similar to MongoDB. http://www.mongodb.org/display/DOCS/Advanced+Queries#AdvancedQueries-%24ne | ||
|
||
User.where(:name => {:not => 'foo'}) | ||
=> SELECT "users".* FROM "users" WHERE ("users"."name" != 'foo') | ||
|
||
* hash_key | ||
Put the whole key + value Hash into another Hash indexed by +:not+. | ||
|
||
User.where(:not => {:name => 'foo'}) | ||
=> SELECT "users".* FROM "users" WHERE ("users"."name" != 'foo') | ||
|
||
* symbol | ||
Put +:not+ as the first parameter of +where+ method. | ||
|
||
User.where(:not, :name => 'foo') | ||
=> SELECT "users".* FROM "users" WHERE ("users"."name" != 'foo') | ||
|
||
* method | ||
Use the special method named +where_not+. | ||
|
||
User.where_not(:not, :name => 'foo') | ||
=> SELECT "users".* FROM "users" WHERE ("users"."name" != 'foo') | ||
|
||
|
||
== Supported versions | ||
|
||
ActiveRecord 3.0.x, 3.1.x, and 3.2 (edge) | ||
|
||
|
||
== Usage | ||
|
||
Bundle 'everywhere' gem. | ||
|
||
|
||
== Configuring the syntax | ||
|
||
You can choose one from four syntaxes listed above. | ||
For example, if you prefer the symbol syntax, put the following line in your config file. | ||
|
||
config.active_record.where_syntax = :symbol | ||
|
||
The default value is +:hash_value+. | ||
|
||
|
||
== Todo | ||
|
||
+like+ and +not like+ (if needed) | ||
|
||
|
||
== Contributing to Everywhere | ||
|
||
* Fork, fix, then send me a pull request. | ||
|
||
|
||
== Copyright | ||
|
||
Copyright (c) 2011 Akira Matsuda. See MIT-LICENSE for further details. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters