CHANGELOG.md 10.8 KB
Newer Older
1 2 3 4
*   Remove deprecated method `#sanitize_conditions`.

    *Rafael Mendonça França*

5 6 7 8
*   Remove deprecated method `#scope_chain`.

    *Rafael Mendonça França*

9 10 11 12
*   Remove deprecated configuration `.error_on_ignored_order_or_limit`.

    *Rafael Mendonça França*

13 14 15 16
*   Remove deprecated arguments from `#verify!`.

    *Rafael Mendonça França*

17 18 19 20
*   Remove deprecated argument `name` from `#indexes`.

    *Rafael Mendonça França*

21 22 23 24
*   Remove deprecated method `ActiveRecord::Migrator.schema_migrations_table_name`.

    *Rafael Mendonça França*

25 26 27 28
*   Remove deprecated method `supports_primary_key?`.

    *Rafael Mendonça França*

29 30 31 32
*   Remove deprecated method `supports_migrations?`.

    *Rafael Mendonça França*

33 34 35 36
*   Remove deprecated methods `initialize_schema_migrations_table` and `initialize_internal_metadata_table`.

    *Rafael Mendonça França*

37 38 39 40
*   Raises when calling `lock!` in a dirty record.

    *Rafael Mendonça França*

41 42 43 44
*   Remove deprecated support to passing a class to `:class_name` on associations.

    *Rafael Mendonça França*

45 46 47 48
*   Remove deprecated argument `default` from `index_name_exists?`.

    *Rafael Mendonça França*

49 50 51 52
*   Remove deprecated support to `quoted_id` when typecasting an Active Record object.

    *Rafael Mendonça França*

53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
*   Fix `bin/rails db:setup` and `bin/rails db:test:prepare` create  wrong
    ar_internal_metadata's data for a test database.

    Before:
    ```
    $ RAILS_ENV=test rails dbconsole
    > SELECT * FROM ar_internal_metadata;
    key|value|created_at|updated_at
    environment|development|2017-09-11 23:14:10.815679|2017-09-11 23:14:10.815679
    ```

    After:
    ```
    $ RAILS_ENV=test rails dbconsole
    > SELECT * FROM ar_internal_metadata;
    key|value|created_at|updated_at
    environment|test|2017-09-11 23:14:10.815679|2017-09-11 23:14:10.815679
    ```

    Fixes #26731.

    *bogdanvlviv*

76 77 78 79 80 81
*   Fix longer sequence name detection for serial columns.

    Fixes #28332.

    *Ryuta Kamizono*

82 83 84 85 86 87
*   MySQL: Don't lose `auto_increment: true` in the `db/schema.rb`.

    Fixes #30894.

    *Ryuta Kamizono*

88 89 90 91 92 93
*   Fix `COUNT(DISTINCT ...)` for `GROUP BY` with `ORDER BY` and `LIMIT`.

    Fixes #30886.

    *Ryuta Kamizono*

R
Ryuta Kamizono 已提交
94
*   PostgreSQL `tsrange` now preserves subsecond precision.
95 96

    PostgreSQL 9.1+ introduced range types, and Rails added support for using
R
Ryuta Kamizono 已提交
97 98
    this datatype in Active Record. However, the serialization of
    `PostgreSQL::OID::Range` was incomplete, because it did not properly
99 100 101
    cast the bounds that make up the range. This led to subseconds being
    dropped in SQL commands:

R
Ryuta Kamizono 已提交
102
    Before:
103

R
Ryuta Kamizono 已提交
104 105
        connection.type_cast(tsrange.serialize(range_value))
        # => "[2010-01-01 13:30:00 UTC,2011-02-02 19:30:00 UTC)"
106

R
Ryuta Kamizono 已提交
107
    Now:
108

R
Ryuta Kamizono 已提交
109 110 111 112
        connection.type_cast(tsrange.serialize(range_value))
        # => "[2010-01-01 13:30:00.670277,2011-02-02 19:30:00.745125)"

    *Thomas Cannon*
113

114 115 116 117 118
*   Passing a `Set` to `Relation#where` now behaves the same as passing an
    array.

    *Sean Griffin*

119 120 121 122 123 124
*   Use given algorithm while removing index from database.

    Fixes #24190.

    *Mehmet Emin İNAÇ*

125 126 127 128 129 130 131
*   Update payload names for `sql.active_record` instrumentation to be
    more descriptive.

    Fixes #30586.

    *Jeremy Green*

132 133 134 135 136
*   Add new error class `TransactionTimeout` for MySQL adapter which will be raised
    when lock wait time expires.

    *Gabriel Courtemanche*

137 138 139 140
*   Remove deprecated `#migration_keys`.

    *Ryuta Kamizono*

141 142 143 144
*   Automatically guess the inverse associations for STI.

    *Yuichiro Kaneko*

145 146
*   Ensure `sum` honors `distinct` on `has_many :through` associations

R
Ryuta Kamizono 已提交
147
    Fixes #16791.
148

R
Ryuta Kamizono 已提交
149
    *Aaron Wortham*
150

Y
yalab 已提交
151 152 153 154
*   Add `binary` fixture helper method.

    *Atsushi Yoshida*

155
*   When using `Relation#or`, extract the common conditions and put them before the OR condition.
156 157 158

    *Maxime Handfield Lapointe*

159 160 161 162 163 164 165
*   `Relation#or` now accepts two relations who have different values for
    `references` only, as `references` can be implicitly called by `where`.

    Fixes #29411.

    *Sean Griffin*

J
Jon Moss 已提交
166
*   `ApplicationRecord` is no longer generated when generating models. If you
167 168 169 170
    need to generate it, it can be created with `rails g application_record`.

    *Lisa Ugray*

171 172 173 174
*   Fix `COUNT(DISTINCT ...)` with `ORDER BY` and `LIMIT` to keep the existing select list.

    *Ryuta Kamizono*

175 176 177 178 179 180
*   When a `has_one` association is destroyed by `dependent: destroy`,
    `destroyed_by_association` will now be set to the reflection, matching the
    behaviour of `has_many` associations.

    *Lisa Ugray*

181 182 183 184 185 186 187 188 189 190 191 192 193 194 195
*   Fix `unscoped(where: [columns])` removing the wrong bind values

    When the `where` is called on a relation after a `or`, unscoping the column of that later `where` removed
    bind values used by the `or` instead. (possibly other cases too)

    ```
    Post.where(id: 1).or(Post.where(id: 2)).where(foo: 3).unscope(where: :foo).to_sql
    # Currently:
    #     SELECT "posts".* FROM "posts" WHERE ("posts"."id" = 2 OR "posts"."id" = 3)
    # With fix:
    #     SELECT "posts".* FROM "posts" WHERE ("posts"."id" = 1 OR "posts"."id" = 2)
    ```

    *Maxime Handfield Lapointe*

196 197 198 199 200
*   Values constructed using multi-parameter assignment will now use the
    post-type-cast value for rendering in single-field form inputs.

    *Sean Griffin*

201 202 203 204 205 206 207
*   `Relation#joins` is no longer affected by the target model's
    `current_scope`, with the exception of `unscoped`.

    Fixes #29338.

    *Sean Griffin*

208 209 210 211 212 213 214 215 216 217 218
*   Change sqlite3 boolean serialization to use 1 and 0

    SQLite natively recognizes 1 and 0 as true and false, but does not natively
    recognize 't' and 'f' as was previously serialized.

    This change in serialization requires a migration of stored boolean data
    for SQLite databases, so it's implemented behind a configuration flag
    whose default false value is deprecated.

    *Lisa Ugray*

219 220 221 222 223 224 225 226
*   Skip query caching when working with batches of records (`find_each`, `find_in_batches`,
    `in_batches`).

    Previously, records would be fetched in batches, but all records would be retained in memory
    until the end of the request or job.

    *Eugene Kenny*

R
Ryuta Kamizono 已提交
227 228
*   Prevent errors raised by `sql.active_record` notification subscribers from being converted into
    `ActiveRecord::StatementInvalid` exceptions.
229 230 231

    *Dennis Taylor*

232 233 234 235 236 237
*   Fix eager loading/preloading association with scope including joins.

    Fixes #28324.

    *Ryuta Kamizono*

238 239
*   Fix transactions to apply state to child transactions

J
Jon Moss 已提交
240
    Previously, if you had a nested transaction and the outer transaction was rolledback, the record from the
241 242 243 244 245 246 247
    inner transaction would still be marked as persisted.

    This change fixes that by applying the state of the parent transaction to the child transaction when the
    parent transaction is rolledback. This will correctly mark records from the inner transaction as not persisted.

    *Eileen M. Uchitelle*, *Aaron Patterson*

248 249 250 251 252 253 254 255
*   Deprecate `set_state` method in `TransactionState`

    Deprecated the `set_state` method in favor of setting the state via specific methods. If you need to mark the
    state of the transaction you can now use `rollback!`, `commit!` or `nullify!` instead of
    `set_state(:rolledback)`, `set_state(:committed)`, or `set_state(nil)`.

    *Eileen M. Uchitelle*, *Aaron Patterson*

256 257 258 259
*   Deprecate delegating to `arel` in `Relation`.

    *Ryuta Kamizono*

260 261 262 263
*   Fix eager loading to respect `store_full_sti_class` setting.

    *Ryuta Kamizono*

R
Ryuta Kamizono 已提交
264
*   Query cache was unavailable when entering the `ActiveRecord::Base.cache` block
265 266 267 268
    without being connected.

    *Tsukasa Oishi*

269 270 271 272 273 274 275
*   Previously, when building records using a `has_many :through` association,
    if the child records were deleted before the parent was saved, they would
    still be persisted. Now, if child records are deleted before the parent is saved
    on a `has_many :through` association, the child records will not be persisted.

    *Tobias Kraze*

276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291
*   Merging two relations representing nested joins no longer transforms the joins of
    the merged relation into LEFT OUTER JOIN. Example to clarify:

    ```
    Author.joins(:posts).merge(Post.joins(:comments))
    # Before the change:
    #=> SELECT ... FROM authors INNER JOIN posts ON ... LEFT OUTER JOIN comments ON...

    # After the change:
    #=> SELECT ... FROM authors INNER JOIN posts ON ... INNER JOIN comments ON...
    ```

    TODO: Add to the Rails 5.2 upgrade guide

    *Maxime Handfield Lapointe*

292 293 294 295 296
*   `ActiveRecord::Persistence#touch` does not work well when optimistic locking enabled and
    `locking_column`, without default value, is null in the database.

    *bogdanvlviv*

297
*   Fix destroying existing object does not work well when optimistic locking enabled and
R
Ryuta Kamizono 已提交
298
    `locking_column` is null in the database.
299 300 301

    *bogdanvlviv*

K
Kir Shatrov 已提交
302 303 304 305
*   Use bulk INSERT to insert fixtures for better performance.

    *Kir Shatrov*

J
Jon Moss 已提交
306
*   Prevent creation of bind param if casted value is nil.
307 308 309

    *Ryuta Kamizono*

310 311 312 313
*   Deprecate passing arguments and block at the same time to `count` and `sum` in `ActiveRecord::Calculations`.

    *Ryuta Kamizono*

314 315 316 317 318 319
*   Loading model schema from database is now thread-safe.

    Fixes #28589.

    *Vikrant Chaudhary*, *David Abdemoulaie*

R
Ryuta Kamizono 已提交
320 321
*   Add `ActiveRecord::Base#cache_version` to support recyclable cache keys via the new versioned entries
    in `ActiveSupport::Cache`. This also means that `ActiveRecord::Base#cache_key` will now return a stable key
322
    that does not include a timestamp any more.
R
Ryuta Kamizono 已提交
323 324 325 326

    NOTE: This feature is turned off by default, and `#cache_key` will still return cache keys with timestamps
    until you set `ActiveRecord::Base.cache_versioning = true`. That's the setting for all new apps on Rails 5.2+

327 328
    *DHH*

R
Ryuta Kamizono 已提交
329
*   Respect `SchemaDumper.ignore_tables` in rake tasks for databases structure dump
G
Guillermo Iguaran 已提交
330 331 332

    *Rusty Geldmacher*, *Guillermo Iguaran*

333 334 335 336 337 338
*   Add type caster to `RuntimeReflection#alias_name`

    Fixes #28959.

    *Jon Moss*

339 340 341 342
*   Deprecate `supports_statement_cache?`.

    *Ryuta Kamizono*

R
Ryuta Kamizono 已提交
343
*   Quote database name in `db:create` grant statement (when database user does not have access to create the database).
344 345 346

    *Rune Philosof*

347 348 349 350 351
*   Raise error `UnknownMigrationVersionError` on the movement of migrations
    when the current migration does not exist.

    *bogdanvlviv*

352 353 354 355
*   Fix `bin/rails db:forward` first migration.

    *bogdanvlviv*

356 357 358 359 360 361 362
*   Support Descending Indexes for MySQL.

    MySQL 8.0.1 and higher supports descending indexes: `DESC` in an index definition is no longer ignored.
    See https://dev.mysql.com/doc/refman/8.0/en/descending-indexes.html.

    *Ryuta Kamizono*

363 364 365 366
*   Fix inconsistency with changed attributes when overriding AR attribute reader.

    *bogdanvlviv*

J
Jon Moss 已提交
367
*   When calling the dynamic fixture accessor method with no arguments, it now returns all fixtures of this type.
368 369 370 371 372
    Previously this method always returned an empty array.

    *Kevin McPhillips*


M
Matthew Draper 已提交
373
Please check [5-1-stable](https://github.com/rails/rails/blob/5-1-stable/activerecord/CHANGELOG.md) for previous changes.