2013-06-19 12:27:13 -04:00
|
|
|
* `inspect` on Active Record model classes does not initiate a
|
|
|
|
new connection. This means that calling `inspect`, when the
|
|
|
|
database is missing, will no longer raise an exception.
|
|
|
|
Fixes #10936.
|
|
|
|
|
|
|
|
Example:
|
|
|
|
|
|
|
|
Author.inspect # => "Author(no database connection)"
|
|
|
|
|
|
|
|
*Yves Senn*
|
|
|
|
|
2013-06-19 12:28:49 -04:00
|
|
|
* Handle single quotes in PostgreSQL default column values.
|
|
|
|
Fixes #10881.
|
|
|
|
|
|
|
|
*Dylan Markow*
|
|
|
|
|
2013-06-18 04:46:33 -04:00
|
|
|
* Log the sql that is actually sent to the database.
|
|
|
|
|
|
|
|
If I have a query that produces sql
|
|
|
|
`WHERE "users"."name" = 'a b'` then in the log all the
|
|
|
|
whitespace is being squeezed. So the sql that is printed in the
|
|
|
|
log is `WHERE "users"."name" = 'a b'`.
|
|
|
|
|
|
|
|
Do not squeeze whitespace out of sql queries. Fixes #10982.
|
|
|
|
|
|
|
|
*Neeraj Singh*
|
|
|
|
|
2013-06-10 07:52:22 -04:00
|
|
|
* Fixture setup does no longer depend on `ActiveRecord::Base.configurations`.
|
|
|
|
This is relevant when `ENV["DATABASE_URL"]` is used in place of a `database.yml`.
|
|
|
|
|
|
|
|
*Yves Senn*
|
|
|
|
|
2013-06-12 08:15:15 -04:00
|
|
|
* Fix mysql2 adapter raises the correct exception when executing a query on a
|
|
|
|
closed connection.
|
|
|
|
|
|
|
|
*Yves Senn*
|
|
|
|
|
2013-06-13 12:46:30 -04:00
|
|
|
* Ambiguous reflections are on :through relationships are no longer supported.
|
|
|
|
For example, you need to change this:
|
|
|
|
|
2013-06-18 15:12:24 -04:00
|
|
|
class Author < ActiveRecord::Base
|
|
|
|
has_many :posts
|
|
|
|
has_many :taggings, :through => :posts
|
|
|
|
end
|
2013-06-15 08:34:55 -04:00
|
|
|
|
2013-06-18 15:12:24 -04:00
|
|
|
class Post < ActiveRecord::Base
|
|
|
|
has_one :tagging
|
|
|
|
has_many :taggings
|
|
|
|
end
|
2013-06-15 08:34:55 -04:00
|
|
|
|
2013-06-18 15:12:24 -04:00
|
|
|
class Tagging < ActiveRecord::Base
|
|
|
|
end
|
2013-06-13 12:46:30 -04:00
|
|
|
|
|
|
|
To this:
|
|
|
|
|
2013-06-18 15:12:24 -04:00
|
|
|
class Author < ActiveRecord::Base
|
|
|
|
has_many :posts
|
|
|
|
has_many :taggings, :through => :posts, :source => :tagging
|
|
|
|
end
|
2013-06-15 08:34:55 -04:00
|
|
|
|
2013-06-18 15:12:24 -04:00
|
|
|
class Post < ActiveRecord::Base
|
|
|
|
has_one :tagging
|
|
|
|
has_many :taggings
|
|
|
|
end
|
2013-06-15 08:34:55 -04:00
|
|
|
|
2013-06-18 15:12:24 -04:00
|
|
|
class Tagging < ActiveRecord::Base
|
|
|
|
end
|
2013-06-13 12:46:30 -04:00
|
|
|
|
2013-06-18 15:16:26 -04:00
|
|
|
*Aaron Peterson*
|
|
|
|
|
2013-05-13 13:31:00 -04:00
|
|
|
* Remove column restrictions for `count`, let the database raise if the SQL is
|
2013-06-12 05:45:52 -04:00
|
|
|
invalid. The previous behavior was untested and surprising for the user.
|
2013-05-13 13:31:00 -04:00
|
|
|
Fixes #5554.
|
|
|
|
|
|
|
|
Example:
|
|
|
|
|
|
|
|
User.select("name, username").count
|
|
|
|
# Before => SELECT count(*) FROM users
|
|
|
|
# After => ActiveRecord::StatementInvalid
|
|
|
|
|
|
|
|
# you can still use `count(:all)` to perform a query unrelated to the
|
|
|
|
# selected columns
|
|
|
|
User.select("name, username").count(:all) # => SELECT count(*) FROM users
|
|
|
|
|
|
|
|
*Yves Senn*
|
|
|
|
|
2013-06-07 23:59:27 -04:00
|
|
|
* Rails now automatically detects inverse associations. If you do not set the
|
|
|
|
`:inverse_of` option on the association, then Active Record will guess the
|
|
|
|
inverse association based on heuristics.
|
|
|
|
|
|
|
|
Note that automatic inverse detection only works on `has_many`, `has_one`,
|
|
|
|
and `belongs_to` associations. Extra options on the associations will
|
|
|
|
also prevent the association's inverse from being found automatically.
|
|
|
|
|
|
|
|
The automatic guessing of the inverse association uses a heuristic based
|
|
|
|
on the name of the class, so it may not work for all associations,
|
|
|
|
especially the ones with non-standard names.
|
|
|
|
|
|
|
|
You can turn off the automatic detection of inverse associations by setting
|
|
|
|
the `:inverse_of` option to `false` like so:
|
|
|
|
|
2013-06-18 15:12:24 -04:00
|
|
|
class Taggable < ActiveRecord::Base
|
|
|
|
belongs_to :tag, inverse_of: false
|
|
|
|
end
|
2013-06-07 23:59:27 -04:00
|
|
|
|
|
|
|
*John Wang*
|
|
|
|
|
2013-05-05 22:06:12 -04:00
|
|
|
* Fix `add_column` with `array` option when using PostgreSQL. Fixes #10432
|
|
|
|
|
|
|
|
*Adam Anderson*
|
|
|
|
|
2013-05-27 10:52:42 -04:00
|
|
|
* Usage of `implicit_readonly` is being removed`. Please use `readonly` method
|
|
|
|
explicitly to mark records as `readonly.
|
|
|
|
Fixes #10615.
|
|
|
|
|
|
|
|
Example:
|
|
|
|
|
|
|
|
user = User.joins(:todos).select("users.*, todos.title as todos_title").readonly(true).first
|
|
|
|
user.todos_title = 'clean pet'
|
|
|
|
user.save! # will raise error
|
|
|
|
|
|
|
|
*Yves Senn*
|
|
|
|
|
2013-05-21 11:59:37 -04:00
|
|
|
* Fix the `:primary_key` option for `has_many` associations.
|
|
|
|
Fixes #10693.
|
|
|
|
|
|
|
|
*Yves Senn*
|
|
|
|
|
2013-06-12 05:45:52 -04:00
|
|
|
* Fix bug where tiny types are incorrectly coerced as boolean when the length is more than 1.
|
2013-05-22 13:40:32 -04:00
|
|
|
|
|
|
|
Fixes #10620.
|
|
|
|
|
|
|
|
*Aaron Peterson*
|
|
|
|
|
2013-05-18 09:52:46 -04:00
|
|
|
* Also support extensions in PostgreSQL 9.1. This feature has been supported since 9.1.
|
2013-05-07 13:45:35 -04:00
|
|
|
|
|
|
|
*kennyj*
|
|
|
|
|
2013-05-12 13:49:49 -04:00
|
|
|
* Deprecate `ConnectionAdapters::SchemaStatements#distinct`,
|
|
|
|
as it is no longer used by internals.
|
|
|
|
|
2013-06-18 15:16:26 -04:00
|
|
|
*Ben Woosley*
|
2013-05-12 13:49:49 -04:00
|
|
|
|
2013-05-11 22:51:27 -04:00
|
|
|
* Fix pending migrations error when loading schema and `ActiveRecord::Base.table_name_prefix`
|
|
|
|
is not blank.
|
2013-05-11 22:32:33 -04:00
|
|
|
|
2013-05-11 22:51:27 -04:00
|
|
|
Call `assume_migrated_upto_version` on connection to prevent it from first
|
|
|
|
being picked up in `method_missing`.
|
|
|
|
|
|
|
|
In the base class, `Migration`, `method_missing` expects the argument to be a
|
|
|
|
table name, and calls `proper_table_name` on the arguments before sending to
|
|
|
|
`connection`. If `table_name_prefix` or `table_name_suffix` is used, the schema
|
|
|
|
version changes to `prefix_version_suffix`, breaking `rake test:prepare`.
|
2013-05-11 22:32:33 -04:00
|
|
|
|
|
|
|
Fixes #10411.
|
|
|
|
|
|
|
|
*Kyle Stevens*
|
|
|
|
|
2013-05-11 22:51:27 -04:00
|
|
|
* Method `read_attribute_before_type_cast` should accept input as symbol.
|
2013-05-11 03:08:08 -04:00
|
|
|
|
|
|
|
*Neeraj Singh*
|
|
|
|
|
2013-05-06 18:31:20 -04:00
|
|
|
* Confirm a record has not already been destroyed before decrementing counter cache.
|
|
|
|
|
|
|
|
*Ben Tucker*
|
|
|
|
|
2013-05-06 21:22:43 -04:00
|
|
|
* Fixed a bug in `ActiveRecord#sanitize_sql_hash_for_conditions` in which
|
|
|
|
`self.class` is an argument to `PredicateBuilder#build_from_hash`
|
2013-05-07 13:04:11 -04:00
|
|
|
causing `PredicateBuilder` to call non-existent method
|
2013-05-06 21:22:43 -04:00
|
|
|
`Class#reflect_on_association`.
|
2013-04-25 20:20:33 -04:00
|
|
|
|
|
|
|
*Zach Ohlgren*
|
|
|
|
|
2013-05-03 00:46:18 -04:00
|
|
|
* While removing index if column option is missing then raise IrreversibleMigration exception.
|
|
|
|
|
|
|
|
Following code should raise `IrreversibleMigration`. But the code was
|
|
|
|
failing since options is an array and not a hash.
|
|
|
|
|
|
|
|
def change
|
|
|
|
change_table :users do |t|
|
|
|
|
t.remove_index [:name, :email]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
Fix was to check if the options is a Hash before operating on it.
|
|
|
|
|
|
|
|
Fixes #10419.
|
|
|
|
|
|
|
|
*Neeraj Singh*
|
|
|
|
|
2013-02-25 21:06:35 -05:00
|
|
|
* Do not overwrite manually built records during one-to-one nested attribute assignment
|
|
|
|
|
|
|
|
For one-to-one nested associations, if you build the new (in-memory)
|
|
|
|
child object yourself before assignment, then the NestedAttributes
|
|
|
|
module will not overwrite it, e.g.:
|
|
|
|
|
|
|
|
class Member < ActiveRecord::Base
|
|
|
|
has_one :avatar
|
|
|
|
accepts_nested_attributes_for :avatar
|
|
|
|
|
|
|
|
def avatar
|
|
|
|
super || build_avatar(width: 200)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
member = Member.new
|
|
|
|
member.avatar_attributes = {icon: 'sad'}
|
|
|
|
member.avatar.width # => 200
|
|
|
|
|
|
|
|
*Olek Janiszewski*
|
|
|
|
|
2013-05-28 08:34:47 -04:00
|
|
|
* fixes bug introduced by #3329. Now, when autosaving associations,
|
|
|
|
deletions happen before inserts and saves. This prevents a 'duplicate
|
2013-04-10 23:29:19 -04:00
|
|
|
unique value' database error that would occur if a record being created had
|
|
|
|
the same value on a unique indexed field as that of a record being destroyed.
|
|
|
|
|
|
|
|
*Johnny Holton*
|
|
|
|
|
2013-05-01 14:33:11 -04:00
|
|
|
* Handle aliased attributes in ActiveRecord::Relation.
|
|
|
|
|
|
|
|
When using symbol keys, ActiveRecord will now translate aliased attribute names to the actual column name used in the database:
|
|
|
|
|
|
|
|
With the model
|
|
|
|
|
|
|
|
class Topic
|
|
|
|
alias_attribute :heading, :title
|
|
|
|
end
|
|
|
|
|
|
|
|
The call
|
|
|
|
|
|
|
|
Topic.where(heading: 'The First Topic')
|
|
|
|
|
|
|
|
should yield the same result as
|
|
|
|
|
|
|
|
Topic.where(title: 'The First Topic')
|
|
|
|
|
|
|
|
This also applies to ActiveRecord::Relation::Calculations calls such as `Model.sum(:aliased)` and `Model.pluck(:aliased)`.
|
|
|
|
|
|
|
|
This will not work with SQL fragment strings like `Model.sum('DISTINCT aliased')`.
|
|
|
|
|
|
|
|
*Godfrey Chan*
|
|
|
|
|
2013-04-30 20:24:29 -04:00
|
|
|
* Mute `psql` output when running rake db:schema:load.
|
|
|
|
|
|
|
|
*Godfrey Chan*
|
|
|
|
|
2013-03-07 16:43:00 -05:00
|
|
|
* Trigger a save on `has_one association=(associate)` when the associate contents have changed.
|
|
|
|
|
|
|
|
Fix #8856.
|
|
|
|
|
|
|
|
*Chris Thompson*
|
|
|
|
|
2013-04-30 13:21:23 -04:00
|
|
|
* Abort a rake task when missing db/structure.sql like `db:schema:load` task.
|
|
|
|
|
|
|
|
*kennyj*
|
2013-04-25 20:20:33 -04:00
|
|
|
|
2013-05-02 11:09:59 -04:00
|
|
|
* rake:db:test:prepare falls back to original environment after execution.
|
2013-04-25 20:20:33 -04:00
|
|
|
|
2013-05-02 11:09:59 -04:00
|
|
|
*Slava Markevich*
|
2013-03-23 14:09:53 -04:00
|
|
|
|
2013-04-29 12:06:45 -04:00
|
|
|
Please check [4-0-stable](https://github.com/rails/rails/blob/4-0-stable/activerecord/CHANGELOG.md) for previous changes.
|