This file contains hidden or 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
From 124de9bdb3109236af68d06052ce21a4522059e6 Mon Sep 17 00:00:00 2001 | |
From: Ernie Miller <[email protected]> | |
Date: Wed, 27 Oct 2010 09:43:20 -0400 | |
Subject: [PATCH 1/2] Refactor predication methods to be available to SqlLiterals as well. | |
--- | |
lib/arel.rb | 1 + | |
lib/arel/attributes/attribute.rb | 175 +------------------------------------- | |
lib/arel/nodes/sql_literal.rb | 1 + | |
lib/arel/predications.rb | 177 ++++++++++++++++++++++++++++++++++++++ |
This file contains hidden or 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
From 6cb5f1f85c8af1a37a6a27e6f69c0f41a84bbf2f Mon Sep 17 00:00:00 2001 | |
From: Ernie Miller <[email protected]> | |
Date: Mon, 4 Oct 2010 13:35:38 -0400 | |
Subject: [PATCH 1/2] Convert to model before calling model_name on a record in ActiveModel::Naming | |
--- | |
activemodel/lib/active_model/naming.rb | 6 +++++- | |
1 files changed, 5 insertions(+), 1 deletions(-) | |
diff --git a/activemodel/lib/active_model/naming.rb b/activemodel/lib/active_model/naming.rb |
This file contains hidden or 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
ruby-1.9.2-head > a = Arel::Predicates::Inequality.new(1,1) | |
=> #<Arel::Predicates::Inequality:0x00000101a0b480 @operand=1, @operand2=1> | |
ruby-1.9.2-head > a.is_a?(Arel::Predicates::Equality) | |
=> true | |
ruby-1.9.2-head > Arel::Predicates::Equality === a | |
=> true | |
ruby-1.9.2-head > [a].grep(Arel::Predicates::Equality) | |
=> [#<Arel::Predicates::Inequality:0x00000101a0b480 @operand=1, @operand2=1>] |
This file contains hidden or 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
module ActionView | |
module Helpers | |
class FormBuilder | |
Check = Struct.new(:box, :label) | |
# Behaves almost exactly like the select method, but instead of generating a select tag, | |
# generates Checks. These consist of two attributes, +box+ and +label+, | |
# which are (unsurprisingly) the HTML for the check box and the label. Called without a block, | |
# this method will return an array of check boxes. Called with a block, it will yield each | |
# check box to your template. |
This file contains hidden or 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
ruby-1.9.2-head > params = {:search => {:created_at_gteq => 2.weeks.ago}} | |
=> {:search=>{:created_at_gteq=>Mon, 28 Jun 2010 11:46:34 EDT -04:00}} | |
ruby-1.9.2-head > @search = Article.search(params[:search]) | |
=> #<MetaSearch::Builder:0x00000100ac2820 @relation=[], @base=Article(id: integer, title: string, body: text, created_at: datetime, updated_at: datetime, lookup_id: integer), @opts={}, @join_dependency=#<ActiveRecord::Associations::ClassMethods::JoinDependency:0x00000100ac25c8 @joins=[#<ActiveRecord::Associations::ClassMethods::JoinDependency::JoinBase:0x00000100ac25a0 @active_record=Article(id: integer, title: string, body: text, created_at: datetime, updated_at: datetime, lookup_id: integer), @cached_record={}, @table_joins=nil>], @associations=[], @reflections=[], @base_records_hash={}, @base_records_in_order=[], @table_aliases={"articles"=>1}>, @search_attributes={"created_at_greater_than_or_equal_to"=>Mon, 28 Jun 2010 11:46:34 EDT -04:00}> | |
ruby-1.9.2-head > @search.created_at_lteq ||= @search.creat |
This file contains hidden or 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
Autojoin sample results: | |
a = Article.includes(:comments).where(:comments => {:moderations => {:value => 1},:body => 'hey'}).autojoin | |
Article Load (0.4ms) SELECT "articles".* FROM "articles" INNER JOIN "comments" ON "comments"."article_id" = "articles"."id" INNER JOIN "moderations" ON "moderations"."comment_id" = "comments"."id" WHERE (("moderations"."value" = 1 AND "comments"."body" = 'hey')) | |
Comment Load (0.4ms) SELECT "comments".* FROM "comments" WHERE ("comments".article_id = 1) | |
a = Article.eager_load(:moderations).where(:comments => {:moderations => {:value => 1},:body => 'hey'}).autojoin.first | |
Article Load (0.3ms) SELECT DISTINCT "articles".id FROM "articles" LEFT OUTER JOIN "comments" ON "articles"."id" = "comments"."article_id" LEFT OUTER JOIN "moderations" ON "moderations"."comment_id" = "comments"."id" INNER JOIN "comments" "comments_articles" ON "comments_articles"."article_id" = "articles"."id" INNER JOIN "moderations" "moderations_comments" ON "moderations_comments"."comment_id" |
This file contains hidden or 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
From f2bd8bd136b206c6ff48b8c2633e8ab8ca224eb1 Mon Sep 17 00:00:00 2001 | |
From: Ernie Miller <[email protected]> | |
Date: Tue, 13 Apr 2010 10:45:44 -0400 | |
Subject: [PATCH] New predicates, including Not (Unary), Any/All (Polyadic), and NotMatch/NotIn (Binary) | |
This patch adds support for some new types of predicates and | |
cleans up a few small things. Tests are included. | |
It adds a unary predicate, Not. Predicate#not will negate the predicate | |
on which it's called. |
NewerOlder