Commit Graph

48868 Commits

Author SHA1 Message Date
Sean Griffin
e7e1b68093 Merge pull request #18213 from agrobbin/moar-concerns
Actually autoload all second-level directories called `app/*/concerns`
2014-12-28 14:30:05 -07:00
Yves Senn
ed7196645c docs, cleanup Active Record CHANGELOG. [ci skip] 2014-12-28 22:25:42 +01:00
Sean Griffin
559489f10e Merge pull request #18229 from benprew/patch-2
Update example test documentation
2014-12-28 14:20:24 -07:00
Ben Prew
75df8b9a77 Update example test documentation
Example does not work with session headers, should use request headers. [ci skip]
2014-12-28 13:10:01 -08:00
Guillermo Iguaran
a2108132ed Merge pull request #18226 from kamipo/fix_warning_interpreted_as_argument_prefix
Fix warning: `*' interpreted as argument prefix
2014-12-28 02:42:27 -05:00
Ryuta Kamizono
5f1a9bbec0 Fix warning: `*' interpreted as argument prefix 2014-12-28 16:05:53 +09:00
Sean Griffin
3ba552fb29 Merge pull request #18225 from DanOlson/update-without-changing-timestamps
Provide :touch option to save() to accommodate saving without updating t...
2014-12-27 21:44:30 -07:00
Dan Olson
e780e2fda3 Provide :touch option to save() to accommodate saving without updating timestamps. [#18202] 2014-12-27 22:22:37 -06:00
Sean Griffin
307ec3db0f Provide a better error message for unsupported classes in serialize
We only support classes which provide a no-args constructor to use as a
default value. We can provide a more helpful error message if we catch
this when `serialize` is called, rather than letting it error when you
try to assign the attribute.

Fixes #18224
2014-12-27 19:49:09 -07:00
Sean Griffin
cd84b27ca4 Merge pull request #18220 from kamipo/bigint_primary_key_support
Add bigint primary key support for MySQL.
2014-12-27 19:35:30 -07:00
Ryuta Kamizono
a327a9dc58 Add bigint primary key support for MySQL.
Example:

    create_table :foos, id: :bigint do |t|
    end
2014-12-28 05:35:03 +09:00
Ryuta Kamizono
3cbfba6881 Support for any type primary key. 2014-12-28 05:35:03 +09:00
Yves Senn
baaad864e8 add autoload for ForeignKeyDefinition.
/cc @sgrif
2014-12-27 19:43:42 +01:00
Yves Senn
e2d8553005 reduce duplication in ConnectionAdapters::Table docs. [ci skip]
Most of the documentation very closely mirrors the matching
docs from `SchemaStatements`. I reduced duplicated copy and
added links to the underlying methods for the user to follow.
2014-12-27 19:09:43 +01:00
Aditya Kapoor
b2ab4512fb Add a note about non-buffering servers for AC::Live
[ci skip]
2014-12-27 15:45:20 +01:00
Sean Griffin
fc8d638549 Merge pull request #18221 from kamipo/refactor_table_definition_primary_key
Refactor `PostgreSQL::TableDefinition#primary_key`
2014-12-27 07:40:33 -07:00
Ryuta Kamizono
11054049ca Refactor PostgreSQL::TableDefinition#primary_key
Because call the `column` method and set the `options[:primary_key]` is
handled at `super`, here need only treat the `options[:default]`.
2014-12-27 23:13:19 +09:00
Jaroslaw Rzeszotko
879a0f5e07 Flatten the call stacks ActiveSupport::Callbacks produces, fix #18011. 2014-12-27 12:55:29 +01:00
Alex Robbin
4e0ec961e1 actually autoload all second-level directories called app/*/concerns 2014-12-26 23:21:20 -05:00
Sean Griffin
de0cfd27a5 Inform Arel we don't need additional type casting in tests
Part of the larger refactoring to remove type casting from Arel. We can
inform it that we already have the right type by wrapping the value in
an `Arel::Nodes::Quoted`. This commit can be reverted when we have
removed type casting from Arel in Rail 5.1
2014-12-26 17:50:20 -07:00
Sean Griffin
108df8cc90 Inform Arel we don't need additional type casting in batches
Part of the larger refactoring to remove type casting from Arel. We can
inform it that we already have the right type by wrapping the value in
an `Arel::Nodes::Quoted`. This commit can be reverted when we have
removed type casting from Arel in Rail 5.1
2014-12-26 17:48:08 -07:00
Sean Griffin
50d7e448e8 Inform Arel that we don't need additional type casting in batching
Part of the larger refactoring to remove type casting from Arel. We can
inform it that we already have the right type by wrapping the value in
an `Arel::Nodes::Quoted`. This commit can be reverted when we have
removed type casting from Arel in Rail 5.1
2014-12-26 17:45:01 -07:00
Sean Griffin
15e2d5043f Go through normal update_all logic when updating lock columns 2014-12-26 17:36:47 -07:00
Sean Griffin
0520e6559e Go through normal update_all logic when updating counter caches
Part of a larger refactoring to remove type casting behavior from Arel
2014-12-26 17:30:58 -07:00
Sean Griffin
796574c92c We don't need additional type casting for locking updates
Part of the larger refactoring to remove type casting from Arel. We can
inform it that we already have the right type by wrapping the value in
an `Arel::Nodes::Quoted`. This commit can be reverted when we have
removed type casting from Arel in Rail 5.1
2014-12-26 17:17:01 -07:00
Sean Griffin
a61a85683a Inform Arel that we don't need type casting in tests
Part of the larger refactoring to remove type casting from Arel. We can
inform it that we already have the right type by wrapping the value in
an `Arel::Nodes::Quoted`. This commit can be reverted when we have
removed type casting from Arel in Rail 5.1
2014-12-26 17:06:43 -07:00
Sean Griffin
3eb16cea7e Go through normal where logic in apply_join_dependency
Part of the larger refactoring to remove type casting from Arel.
2014-12-26 17:02:40 -07:00
Sean Griffin
8ce6fd5594 Inform Arel that we don't need to cast a value in tests
Part of the larger refactoring to remove type casting from Arel. We can
inform it that we already have the right type by wrapping the value in
an `Arel::Nodes::Quoted`. This commit can be reverted when we have
removed type casting from Arel in Rail 5.1
2014-12-26 17:01:05 -07:00
Sean Griffin
b4e6e47471 We don't need to type cast the offset in find_in_batches
Part of the larger refactoring to remove type casting from Arel. We can
inform it that we already have the right type by wrapping the value in
an `Arel::Nodes::Quoted`. This commit can be reverted when we have
removed type casting from Arel in Rail 5.1
2014-12-26 16:56:24 -07:00
Sean Griffin
a11a8ff784 Fall back to type casting from the connection adapter
There are several valid cases where right now we can't determine the
association's class in a call to `where`. In these cases, we can fall
back to casting by looking up the column from the connection adapter
(which is what happens right now when we fall through to Arel)

This is ugly, and since we're trying to separate the concept of a type
from a column, I'd like to remove it in the future. The problem
basically comes down to this:

    Liquid.joins(molecules: :electrons)
      .where("molecules.name" => "something", "electrons.name" => "something")

The hash in this case will turn into:

    {
      molecules: { name: "something" },
      electrons: { name: "something" },
    }

What we actually need is:

    {
      molecules: {
        name: "something",
        electrons: { name: "something" },
      }
    }

/cc @mrgilman
2014-12-26 16:54:12 -07:00
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