Commit Graph

48619 Commits

Author SHA1 Message Date
Sean Griffin
5f521cbff3 Go through normal where logic in uniqueness validation
This code could use some much heavier refactoring. It looks like
`build_relation` duplicates most of the logic of `Relation#where` and
`PredicateBuilder` with regards to handling associations and attribute
aliases
2014-12-26 16:28:36 -07:00
Sean Griffin
efe5986696 We don't need to cast the value a second time in uniqueness validations
Part of the larger refactoring to remove type casting from Arel. Since
we've already cast the value a few lines above, we don't need to re-cast
it later. We can inform Arel of this by wrapping it in an
`Arel::Nodes::Quoted`, which will no longer be required in Rails 5.1
2014-12-26 16:21:38 -07:00
Sean Griffin
0936972634 We don't need to perform type casting on the STI condition
We will always have the correct type for this query, so no casting is
needed. We inform Arel that we already have the right type by wrapping
it in an `Arel::Nodes::Quoted` (which we will no longer need to do in
Rails 5.1)
2014-12-26 16:17:01 -07:00
Sean Griffin
b98668decb Go through normal where logic when preloading associations
This will allow eager type casting to take place as needed. There
doesn't seem to be any particular reason that the `in` statement was
forced for single values, and the commit message where it was introduced
gives no context.

See
d90b4e2615
2014-12-26 16:12:56 -07:00
Sean Griffin
6d4a19cd50 Eagerly cast array values passed to the predicate builder
Part of a larger refactoring to remove type casting from Arel.

/cc @mrgilman

[Sean Griffin & Melanie Gilman]
2014-12-26 15:57:18 -07:00
Sean Griffin
eac4658bb2 Eagerly cast range values in the predicate builder
A custom object is required for this, as you cannot build a range
object out of `Arel::Nodes::Quoted` objects. Depends on the changes
introduced in
cf03bd45e3

/cc @mrgilman
2014-12-26 15:52:57 -07:00
Sean Griffin
3179b4a868 Perform casting of single values within the predicate builder
As part of the larger refactoring to remove type casting from Arel, we
need to do the casting of values eagerly. The predicate builder is the
closest place that knows about the Active Record class, and can
therefore have the type information.

/cc @mrgilman

[Sean Griffin & Melanie Gilman]
2014-12-26 15:33:57 -07:00
Sean Griffin
a60770d3bf Remove klass and arel_table as a dependency of PredicateBuilder
This class cares far too much about the internals of other parts of
Active Record. This is an attempt to break out a meaningful object which
represents the needs of the predicate builder. I'm not fully satisfied
with the name, but the general concept is an object which represents a
table, the associations to/from that table, and the types associated
with it. Many of these exist at the `ActiveRecord::Base` class level,
not as properties of the table itself, hence the need for another
object. Currently it provides these by holding a reference to the class,
but that will likely change in the future. This allows the predicate
builder to remain wholy concerned with building predicates.

/cc @mrgilman
2014-12-26 15:19:42 -07:00
Sean Griffin
35362817b1 Fix new warning in ruby 2.2 2014-12-26 15:13:08 -07:00
Sean Griffin
3bbe88ecd7 Refactor association handling in PredicateBuilder
I'm attempting to remove `klass` as a dependency of the predicate
builder, in favor of an object that better represents what we're using
it for. The only part of this which doesn't fit nicely into that picture
is the check for an association being polymorphic. Since I'm not yet
sure what that is going to look like, I've moved this logic into another
class in an attempt to separate things that will change from things that
won't.
2014-12-26 14:44:48 -07:00
Sean Griffin
392a453b10 Re-use the predicate builder in the ArrayHandler
This reduces the number of places which will need to care about single
value or range specific logic as we introduce type casting. The array
handler is only responsible for producing `in` statements.

/cc @mrgilman

[Sean Griffin & Melanie Gilman]
2014-12-26 14:18:26 -07:00
Sean Griffin
a3936bbe21 Change PredicateBuilder handler methods to instance methods
This will allow us to pass the predicate builder into the constructor of
these handlers. The procs had to be changed to objects, because the
`PredicateBuilder` needs to be marshalable. If we ever decide to make
`register_handler` part of the public API, we should come up with a
better solution which allows procs.

/cc @mrgilman

[Sean Griffin & Melanie Gilman]
2014-12-26 14:12:16 -07:00
Sean Griffin
af55197d86 Add missing :nodoc:
We're accidentally documenting `PredicateBuilder` and `ArrayHandler`
since there's a constant which is missing `# :nodoc:`
2014-12-26 14:03:50 -07:00
Sean Griffin
1d6bb77636 Inject the PredicateBuilder into the Relation instance
Construction of relations can be a hotspot, we don't want to create one
of these in the constructor. This also allows us to do more expensive
things in the predicate builder's constructor, since it's created once
per AR::Base subclass
2014-12-26 13:53:56 -07:00
Sean Griffin
ed1a775da3 Remove unused @relation instance variable
We don't memoize the relation instance
2014-12-26 13:41:53 -07:00
Sean Griffin
f5e6bafe6a Merge branch 'brainopia-remember_frozen_state_in_transaction' 2014-12-26 13:13:27 -07:00
brainopia
c6fd246436 Propagate frozen state during transaction changes 2014-12-26 13:11:10 -07:00
Sean Griffin
a983e1e89c Correctly ignore case_sensitive for UUID uniqueness validation
I think we should deprecate this behavior and just error if you tell us
to do a case insensitive comparison for types which are not case
sensitive. Partially reverts 35592307

Fixes #18195
2014-12-26 13:04:29 -07:00
Robin Dupret
aff03e71b4 Update guides regarding the extension changes
With rails/coffee-rails#61 (and #17241), the `.coffee` extension is
favoured over `.js.coffee`. Respectively, with rails/sass-rails#271
`.scss` and `.sass` are favoured over `.css.scss` and `.css.sass`.

Let's update the documentation to reflect that.

[ci skip]
2014-12-26 18:08:44 +01:00
Yves Senn
9545041fdb Merge pull request #18206 from kamipo/dump_default_nil_for_postgresql_uuid_primary_key
Dump the default `nil` for PostgreSQL UUID primary key.
2014-12-26 14:51:01 +01:00
Ryuta Kamizono
9b3e7b396e Dump the default nil for PostgreSQL UUID primary key. 2014-12-26 17:54:08 +09:00
Guillermo Iguaran
5fed875e90 Merge pull request #18205 from vipulnsward/fix-railties-warning
Fixed warning `possible reference to past scope` from railties
2014-12-26 00:09:40 -05:00
Vipul A M
1faa00c9ec - Changed paths to routing_paths to avoid warning possible reference to past scope 2014-12-26 10:38:00 +05:30
Guillermo Iguaran
9a2194245d Merge pull request #18197 from vipulnsward/fix-ar-2-2warning
Fixed AR warning on ruby 2.2
2014-12-26 00:04:04 -05:00
Guillermo Iguaran
097250e0d8 Merge pull request #18203 from kyledecot/ruby-2.2
Targeting 2.2
2014-12-26 00:03:32 -05:00
Guillermo Iguaran
4fa4146263 Merge pull request #18204 from chocoby/remove-double-space
Remove unnecessary double space
2014-12-26 00:01:56 -05:00
Guillermo Iguaran
122f55ced1 Merge pull request #18194 from claudiob/remove-action-controller-model-naming
Remove ActionController::ModelNaming
2014-12-25 23:56:35 -05:00
Kenta Okamoto
9b67735de9 Remove unnecessary double space 2014-12-26 13:27:23 +09:00
Kyle Decot
acee13be20 targeting 2.2 2014-12-25 23:25:49 -05:00
Zachary Scott
b273c04f15 Add example to get Errored test to pass in Testing guide [ci skip] 2014-12-25 12:21:35 -05:00
Vipul A M
1a9e47777c - Changed target to target_reflection to avoid warning possible reference to past scope 2014-12-25 22:40:32 +05:30
Matthew Draper
d8e0b8ab55 Merge pull request #18196 from PavelPenkov/rails_env_instead_of_rails
Check for Rails.env instead of Rails
2014-12-26 00:47:19 +10:30
Pavel Penkov
290e8e117f Check for Rails.env instead of Rails
`Rails` constant is added by rails-html-sanitizer leading to bugs in
non-Rails apps using ActiveRecord and ActionMailer
2014-12-25 16:34:28 +03:00
claudiob
4761d81923 Remove ActionController::ModelNaming
The methods in these modules are not used anywhere. They used to be
invoked in polymorphic_routes.rb but their usage was removed in e821045.

What is your opinion about removing these methods?

They do belong to the public API, but in reality their code has already been duplicated to ActionView::ModelNaming, since they are used by methods like `dom_id` and `dom_class` to associated records with DOM elements (in
ActionView).

Please tell me if you think that removing this module is a good idea and,
in that case, if the PR is okay as it is, or you'd rather start by showing
a deprecation message, and remove the module in Rails 5.1.
2014-12-25 00:30:46 +01:00
Zachary Scott
a2059068c0 Merge pull request #18185 from ivalkeen/add_missing_guides
List the Active Support Instrumentation guide in the index (as WIP)
2014-12-24 16:05:56 -05:00
Zachary Scott
269a2ea08d Correct grammar to fix #18182 [ci skip] 2014-12-24 16:02:01 -05:00
Zachary Scott
e9fd0e9d76 Merge pull request #18190 from ef718/master
Fix grammar in Caching with Rails docs
2014-12-24 15:05:18 -05:00
Elaine Fang
6968ef44e2 Update grammar [ci skip] 2014-12-24 15:01:06 -05:00
Robin Dupret
ef7e440c97 Fix a few typos [ci skip] 2014-12-24 19:56:00 +01:00
Ivan Tkalin
128b0a1d10 List the Active Support Instrumentation guide in the index (as WIP) 2014-12-24 17:47:56 +01:00
Arun Agrawal
5bf56b77c3 Merge pull request #18183 from danbernier/master
Fix bug in ActionMailer guide.
2014-12-24 17:37:21 +01:00
Dan Bernier
65158a6701 Fix bug in ActionMailer guide.
When setting a mailer's default from address, you have to pass a hash
with a `:from` key; you can't pass just an email address.
2014-12-24 16:12:47 +00:00
Sean Griffin
dbdb104076 Merge pull request #18107 from mkdynamic/add-reply-to-mail-to
Add support for Reply-To field in mail_to helper
2014-12-24 07:10:53 -07:00
Sean Griffin
199390f337 Merge pull request #18180 from vipulnsward/remove-unnecessary-name-passing
Removed unused parameter to cookie serialize method
2014-12-24 07:09:10 -07:00
Vipul A M
7b2728cac1 - Removed unused parameter to cookie serialize method and fixed usage of the same elsewhere 2014-12-24 18:45:55 +05:30
Sean Griffin
5a2d85be4d Merge pull request #18159 from M7/docs-active_record-update_query_method_docs_with_full_description
Describe full behaviour of Active Record's attribute query methods
2014-12-23 17:42:29 -07:00
Michael D.W. Prendergast
c9d86d4148 Clarify that query methods have a custom definition of whether a numeric value is present. [ci skip]
The way Active Record query methods handle numeric values is a special case, and is not part of Rails's standard definition of present. This update attempts to make this more clear in the docs, so that people don't expect Object#present? to return false if used on a number that is zero.
2014-12-23 19:32:49 -05:00
Xavier Noria
6dd4c04b71 removes superfluous regexp group 2014-12-23 23:51:42 +01:00
Xavier Noria
7702974281 warn about reading guides in GitHub
References #18148.
2014-12-23 23:32:50 +01:00
Xavier Noria
f2bdca3bf9 third test to warn against reading guides in GitHub 2014-12-23 23:24:06 +01:00