Commit Graph

296 Commits

Author SHA1 Message Date
Xavier Noria
ff259b5249 moves a CHANGELOG entry from AR to AP 2013-02-19 17:32:32 +01:00
Xavier Noria
2abf217d54 small tweaks in the AR CHANGELOG 2013-02-19 17:32:32 +01:00
John J Wang
4033c50000 Raise an error when query methods have blank arguments, and when blank arguments are meaningless. 2013-02-19 11:15:15 -05:00
Andrew White
bd328f4342 Add CHANGELOG entry for 41ff6a10216f48f43605a1f9cd6094765cab750f
[ci skip]
2013-02-17 16:48:01 +00:00
Yves Senn
4a4ff50459 don't cache invalid subsets when preloading hmt associations.
closes #8423.
2013-02-14 17:46:07 +01:00
James Miller
caabed6c76 Don't call after_commit when creating through an association and save fails, fixes #5802 2013-02-13 12:27:06 -08:00
Sergey Nartimov
9dfef5a46b define Active Record Store accessors in a module
Allow store accessors to be overrided like other attribute methods,
e.g.:

    class User < ActiveRecord::Base
      store :settings, accessors: [ :color, :homepage ], coder: JSON

      def color
        super || 'red'
      end
    end
2013-02-11 17:00:55 +03:00
Guillermo Iguaran
9c5cc89ede Update activerecord/CHANGELOG.md 2013-02-09 12:23:32 -05:00
Guillermo Iguaran
29f3a036e7 Reverting e170014113 (Change behaviour with empty hash in where clause) 2013-02-08 16:53:49 -05:00
Guillermo Iguaran
fa987cb8ec Reverting 16f6f25 (Change behaviour with empty array in where clause) 2013-02-08 14:22:10 -05:00
Carlos Antonio da Silva
01e67316d8 Improve changelog entries in AR
Describe better the changes related to raising errors with empty
array/hash values in where clauses.

[ci skip]
2013-02-08 11:29:48 -02:00
robertomiranda
16f6f2592e Change behaviour with empty array in where clause 2013-02-08 06:37:30 -05:00
robertomiranda
e170014113 Change behaviour with empty hash in where clause 2013-02-08 01:04:32 -05:00
Dylan Smith
a712e08ebe active_record: Quote numeric values compared to string columns. 2013-02-07 04:59:33 -05:00
Carlos Antonio da Silva
7173919af9 Add changelog entry for #9203 about schema dumper with db extensions
[ci skip]
2013-02-06 22:42:29 -02:00
Rafael Mendonça França
adb8fea493 CHANGELOG review 2013-01-31 17:48:59 -02:00
Aaron Stone
4b005fb371 DATABASE_URL parsing should turn numeric strings into numeric types, and
the strings true and false into boolean types, in order to match how
YAML would parse the same values from database.yml and prevent
unexpected type errors in the database adapters.
2013-01-31 09:01:20 -08:00
Carlos Antonio da Silva
2cb576ef36 Refactor to use each_key, remove extra spaces 2013-01-28 23:25:03 -02:00
Jon Leighton
c8d889905d Prevent Relation#merge from collapsing wheres on the RHS
This caused a bug with the new associations implementation, because now
association conditions are represented as Arel nodes internally right up
to when the whole thing gets turned to SQL.

In Rails 3.2, association conditions get turned to raw SQL early on,
which prevents Relation#merge from interfering.

The current implementation was buggy when a default_scope existed on the
target model, since we would basically end up doing:

  default_scope.merge(association_scope)

If default_scope contained a where(foo: 'a') and association_scope
contained a where(foo: 'b').where(foo: 'c') then the merger would see
that the same column is representated on both sides of the merge and
collapse the wheres to all but the last: where(foo: 'c')

Now, the RHS of the merge is left alone.

Fixes #8990
2013-01-27 20:34:52 +00:00
Lilibeth De La Cruz
bc982cbcb3 Fix handling of dirty time zone aware attributes
Previously, when `time_zone_aware_attributes` were enabled, after
changing a datetime or timestamp attribute and then changing it back
to the original value, `changed_attributes` still tracked the
attribute as changed. This caused `[attribute]_changed?` and
`changed?` methods to return true incorrectly.

Example:

    in_time_zone 'Paris' do
      order = Order.new
      original_time = Time.local(2012, 10, 10)
      order.shipped_at = original_time
      order.save
      order.changed? # => false

      # changing value
      order.shipped_at = Time.local(2013, 1, 1)
      order.changed? # => true

      # reverting to original value
      order.shipped_at = original_time
      order.changed? # => false, used to return true
    end
2013-01-26 16:57:33 +00:00
Yves Senn
648def4060 #count in conjunction with #uniq performs distinct count.
closes #6865
2013-01-26 12:16:28 +01:00
bUg
af1ef85ad2 Add postgresql range types support 2013-01-23 13:37:14 +01:00
wangjohn
bbcebb6ab2 Added a changelog entry. 2013-01-20 14:02:12 -05:00
Jon Leighton
5937bd02de Undeprecate the :extend option
Suggested by @dhh.

It doesn't affect the generated SQL, so seems reasonable to continue to
allow it as an association option.
2013-01-18 12:30:47 +00:00
Yves Senn
ec07735641 CollectionAssociation#empty? respects newly builded records 2013-01-13 00:20:38 +01:00
Prem Sichanugrist
ec53106068 Add CHANGELOG entry for YAML parsing removal
This is for commit e80546cdec56a9c3fcaf6217cba08a02d789d2bc.
2013-01-08 16:59:55 -05:00
Tristan Harward
807e176aba Fix error when assigning NaN to an integer column
Also covers any non-castable case by returning nil, which
is in-line with the intention of the former implementation,
but covers the odd cases which respond to to_i but raise
an error when it's called, such as NaN, Infinity and -Infinity.

Fixes #8757
2013-01-06 16:09:40 -05:00
Carlos Antonio da Silva
149b86d97b Move changelog entry in railties to the top
Other minor changelog improvements [ci skip]
2013-01-04 22:49:14 -02:00
Rob Worley
e209107a51 Support for PostgreSQL's ltree data type. 2013-01-04 21:22:34 +00:00
Jason Stirk
8d98c83bbc Fix undefined method `to_i' introduced since 3.2.8
This commit fixes a bug introduced in 96a13fc7 which breaks behaviour of
integer fields.

In 3.2.8, setting the value of an integer field to a non-integer (eg.
Array, Hash, etc.) would default to 1 (true) :

    # 3.2.8
    p = Post.new
    p.category_id = [ 1, 2 ]
    p.category_id # => 1
    p.category_id = { 3 => 4 }
    p.category_id # => 1

In 3.2.9 and above, this will raise a NoMethodError :

    # 3.2.9
    p = Post.new
    p.category_id = [ 1, 2 ]

    NoMethodError: undefined method `to_i' for [1, 2]:Array

Whilst at first blush this appear to be sensible, it combines in bad
ways with scoping.

For example, it is common to use scopes to control access to data :

    @collection = Posts.where(:category_id => [ 1, 2 ])
    @new_post = @collection.new

In 3.2.8, this would work as expected, creating a new Post object
(albeit with @new_post.category_id = 1). However, in 3.2.9 this will
cause the NoMethodError to be raised as above.

It is difficult to avoid triggering this error without descoping before
calling .new, breaking any apps running on 3.2.8 that rely on this
behaviour.

This patch deviates from 3.2.8 in that it does not retain the somewhat
spurious behaviour of setting the attribute to 1. Instead, it explicitly
sets these invalid values to nil :

    p = Post.new
    p.category_id = [ 1, 2 ]
    p.category_id # => nil

This also fixes the situation where a scope using an array will
"pollute" any newly instantiated records.

    @new_post = @collection.new
    @new_post.category_id # => nil

Finally, 3.2.8 exhibited a behaviour where setting an object to an
integer field caused it to be coerced to "1". This has not been
retained, as it is spurious and surprising in the same way that setting
Arrays and Heshes was :

    c = Category.find(6)
    p = Post.new

    # 3.2.8
    p.category_id = c
    p.category_id # => 1

    # This patch
    p.category_id = c
    p.category_id # => nil

This commit includes explicit test cases that expose the original issue
with calling new on a scope that uses an Array. As this is a common
situation, an explicit test case is the best way to prevent regressions
in the future.

It also updates and separates existing tests to be explicit about the
situation that is being tested (eg. AR objects vs. other objects vs.
non-integers)
2013-01-04 10:34:08 +11:00
Guillermo Iguaran
cb2bd4aa61 Merge pull request #8705 from amparo-luna/change_update_attributes_to_update
Rename update_attributes method to update
2013-01-03 09:09:59 -08:00
Amparo Luna + Guillermo Iguaran
d826f14443 Add Changelog entry regarding update_attibutes being renamed to update 2013-01-03 12:04:25 -05:00
Carlos Antonio da Silva
9f200fb296 Changelog improvements [ci skip] 2013-01-02 21:11:11 -02:00
Rafael Mendonça França
5d80da812b Fix CHANGELOG style [ci skip] 2012-12-26 12:19:09 -03:00
Pascal Friederich
5a3dc8092d validate :on option on after_commit and after_rollback callbacks 2012-12-26 11:37:37 +01:00
Marc-Andre Lafortune
a81845f268 Update Migration and 4.0 Release Guides, Changelogs [#8267] 2012-12-21 13:56:16 -05:00
Rafael Mendonça França
f2e0925ab7 Serialized attribute can be serialized in an integer column
Fix #8575
2012-12-21 14:41:13 -03:00
Carlos Antonio da Silva
42b555dcf3 Fix Action Mailer changelog indenation to match other changelogs
Also some minor improvements to other changelogs. [ci skip]
2012-12-19 23:09:04 -02:00
Yves Senn
d01f913f8d Keep index names when using with sqlite3 2012-12-19 09:07:09 +01:00
Gary S. Weaver
9bb27f7ffe #5523 Add ability for postgresql adapter to disable user triggers in disable_referential_integrity. 2012-12-18 10:46:16 -05:00
Pedro Padron
ba98dad113 Added support for validates_uniqueness_of in PostgreSQL array columns. Fixes: #8075. 2012-12-18 08:35:03 -02:00
Alexey
9a4a095ed7 AR supporting new intrange data type on PostgreSQL >= 9.2 2012-12-16 13:11:10 +02:00
Carlos Antonio da Silva
df9f9b7f3e Convert changelogs to 1.9 hash style and fix some formatting [ci skip] 2012-12-14 20:25:22 -02:00
Matthew M. Boedicker
8f59ffce67 Do not log the binding values for binary columns.
They tend to be large and not very useful in the log.
2012-12-14 12:19:17 -08:00
Matthew Robertson
a765c8426f Fix for has_many_through counter_cache bug
This commit fixes reported issue #7630 in which counter
caches were not being updated properly when replacing
has_many_through relationships
2012-12-14 10:03:05 -08:00
Yves Senn
349d460600 recognize migrations, in folders containing numbers and 'rb'.
Closes #8492
2012-12-13 09:08:32 +01:00
Carlos Antonio da Silva
2d3b1dabc9 Remove changelog entry from #8441 [ci skip]
This issue only happens on master due to internal AR refactorings, so
there is no need for a changelog entry.

The test was backported to 3-2-stable to ensure there won't be any regressions.
2012-12-11 08:33:58 -02:00
Rafael Mendonça França
d668544785 Add CHANGELOG entry for #6376.
Conflicts:
	activerecord/CHANGELOG.md
2012-12-10 17:48:31 -03:00
Rafael Mendonça França
9cce1ea2fd Allow users to choose the timestamp format in the cache key
This can be done using the class attribute cache_timestamp_format

Conflicts:
	railties/guides/source/configuring.textile
2012-12-10 17:48:26 -03:00
itzki
7efcc5d72f Fix decorating columns for serialized attributes 2012-12-10 14:44:24 +09:00