CHANGELOG.md 6.8 KB
Newer Older
1 2 3 4
*   Made ActiveRecord consistently use `ActiveRecord::Type` (not `ActiveModel::Type`)

    *Iain Beeston*

5 6 7 8
*   Serialize JSON attribute value `nil` as SQL `NULL`, not JSON `null`

    *Trung Duc Tran*

9 10 11 12 13 14 15
*   Return `true` from `update_attribute` when the value of the attribute
    to be updated is unchanged.

    Fixes #26593.

    *Prathamesh Sonpatki*

16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
*   Always store errors details information with symbols.

    When the association is autosaved we were storing the details with
    string keys. This was creating inconsistency with other details that are
    added using the `Errors#add` method. It was also inconsistent with the
    `Errors#messages` storage.

    To fix this inconsistency we are always storing with symbols. This will
    cause a small breaking change because in those cases the details could
    be accessed as strings keys but now it can not.

    Fix #26499.

    *Rafael Mendonça França*, *Marcus Vieira*

31 32 33 34 35 36 37
*   Calling `touch` on a model using optimistic locking will now leave the model
    in a non-dirty state with no attribute changes.

    Fixes #26496.

    *Jakob Skjerning*

38 39 40 41 42
*   Using a mysql2 connection after it fails to reconnect will now have an error message
    saying the connection is closed rather than an undefined method error message.

    *Dylan Thacker-Smith*

43 44 45 46 47 48 49
*   PostgreSQL array columns will now respect the encoding of strings contained
    in the array.

    Fixes #26326.

    *Sean Griffin*

50 51 52 53 54 55 56
*   Inverse association instances will now be set before `after_find` or
    `after_initialize` callbacks are run.

    Fixes #26320.

    *Sean Griffin*

57 58 59 60 61
*   Remove unnecessarily association load when a `belongs_to` association has already been
    loaded then the foreign key is changed directly and the record saved.

    *James Coleman*

62
*   Remove standardized column types/arguments spaces in schema dump.
63 64 65

    *Tim Petricola*

66 67 68 69 70 71 72
*   Avoid loading records from database when they are already loaded using
    the `pluck` method on a collection.

    Fixes #25921.

    *Ryuta Kamizono*

73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
*   Remove text default treated as an empty string in non-strict mode for
    consistency with other types.

    Strict mode controls how MySQL handles invalid or missing values in
    data-change statements such as INSERT or UPDATE. If strict mode is not
    in effect, MySQL inserts adjusted values for invalid or missing values
    and produces warnings.

        def test_mysql_not_null_defaults_non_strict
          using_strict(false) do
            with_mysql_not_null_table do |klass|
              record = klass.new
              assert_nil record.non_null_integer
              assert_nil record.non_null_string
              assert_nil record.non_null_text
              assert_nil record.non_null_blob

              record.save!
              record.reload

              assert_equal 0,  record.non_null_integer
              assert_equal "", record.non_null_string
              assert_equal "", record.non_null_text
              assert_equal "", record.non_null_blob
            end
          end
        end

    https://dev.mysql.com/doc/refman/5.7/en/sql-mode.html#sql-mode-strict

    *Ryuta Kamizono*

105 106 107 108 109 110 111 112
*   Sqlite3 migrations to add a column to an existing table can now be
    successfully rolled back when the column was given and invalid column
    type.

    Fixes #26087

    *Travis O'Neill*

113 114 115 116
*   Deprecate `sanitize_conditions`. Use `sanitize_sql` instead.

    *Ryuta Kamizono*

117 118 119 120 121
*   Doing count on relations that contain LEFT OUTER JOIN Arel node no longer
    force a DISTINCT. This solves issues when using count after a left_joins.

    *Maxime Handfield Lapointe*

122 123 124 125 126
*   RecordNotFound raised by association.find exposes `id`, `primary_key` and
    `model` methods to be consistent with RecordNotFound raised by Record.find.

    *Michel Pigassou*

127 128 129 130 131 132 133
*   Hashes can once again be passed to setters of `composed_of`, if all of the
    mapping methods are methods implemented on `Hash`.

    Fixes #25978.

    *Sean Griffin*

134 135 136 137
*   Fix the SELECT statement in `#table_comment` for MySQL.

    *Takeshi Akima*

138 139 140 141 142
*   Virtual attributes will no longer raise when read on models loaded from the
    database

    *Sean Griffin*

143 144 145 146
*   Support calling the method `merge` in `scope`'s lambda.

    *Yasuhiro Sugino*

147 148 149 150
*   Fixes multi-parameter attributes conversion with invalid params.

    *Hiroyuki Ishii*

151
*   Add newline between each migration in `structure.sql`.
152 153

    Keeps schema migration inserts as a single commit, but allows for easier
154 155 156
    git diffing.

    Fixes #25504.
157 158 159

    *Grey Baker*, *Norberto Lopes*

160 161 162 163 164 165 166 167 168 169 170 171 172 173 174
*   The flag `error_on_ignored_order_or_limit` has been deprecated in favor of
    the current `error_on_ignored_order`.

    *Xavier Noria*

*   Batch processing methods support `limit`:

        Post.limit(10_000).find_each do |post|
          # ...
        end

    It also works in `find_in_batches` and `in_batches`.

    *Xavier Noria*

175
*   Using `group` with an attribute that has a custom type will properly cast
176 177
    the hash keys after calling a calculation method like `count`.

V
Vipul A M 已提交
178
    Fixes #25595.
179 180 181

    *Sean Griffin*

182
*   Fix the generated `#to_param` method to use `omission: ''` so that
183 184 185 186 187 188
    the resulting output is actually up to 20 characters, not
    effectively 17 to leave room for the default "...".
    Also call `#parameterize` before `#truncate` and make the
    `separator: /-/` to maximize the information included in the
    output.

189
    Fixes #23635.
190 191 192

    *Rob Biedenharn*

193 194 195 196 197 198 199
*   Ensure concurrent invocations of the connection reaper cannot allocate the
    same connection to two threads.

    Fixes #25585.

    *Matthew Draper*

200 201 202 203 204 205
*   Inspecting an object with an associated array of over 10 elements no longer
    truncates the array, preventing `inspect` from looping infinitely in some
    cases.

    *Kevin McPhillips*

206
*   Removed the unused methods `ActiveRecord::Base.connection_id` and
207
    `ActiveRecord::Base.connection_id=`.
208 209 210

    *Sean Griffin*

211
*   Ensure hashes can be assigned to attributes created using `composed_of`.
212

213 214 215 216
    Fixes #25210.

    *Sean Griffin*

217 218
*   Fix logging edge case where if an attribute was of the binary type and
    was provided as a Hash.
R
Rafael Mendonça França 已提交
219

220 221
    *Jon Moss*

222 223 224 225
*   Handle JSON deserialization correctly if the column default from database
    adapter returns `''` instead of `nil`.

    *Johannes Opper*
226

227
*   Introduce `ActiveRecord::TransactionSerializationError` for catching
228 229 230 231
    transaction serialization failures or deadlocks.

    *Erol Fornoles*

V
Vipul A M 已提交
232
*   PostgreSQL: Fix `db:structure:load` silent failure on SQL error.
233

234 235
    The command line flag `-v ON_ERROR_STOP=1` should be used
    when invoking `psql` to make sure errors are not suppressed.
236 237 238 239 240 241 242 243 244 245

    Example:

        psql -v ON_ERROR_STOP=1 -q -f awesome-file.sql my-app-db

    Fixes #23818.

    *Ralin Chimev*


246
Please check [5-0-stable](https://github.com/rails/rails/blob/5-0-stable/activerecord/CHANGELOG.md) for previous changes.