| Commit message (Collapse) | Author | Age | Files | Lines |
... | |
|\ \
| | |
| | | |
autosave_association issue that occurs when table has unique index (resubmission)
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
fixes bug introduced by #3329
These are the conditions necessary to reproduce the bug:
- For an association, autosave => true.
- An association record is being destroyed
- A new association record is being created.
- There is a unique index one of the association's fields.
- The record being created has the same value as the record being
destroyed on the indexed field.
Before, the deletion of records was postponed until after all
insertions/saves. Therefore the new record with the identical value in
the indexed field caused a non-unique value error to be thrown at the database
level.
With this fix, the deletions happen first, before the insertions/saves.
Therefore the record with the duplicate value is gone from the database
before the new record is created, thereby avoiding the non-uniuqe value
error.
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
test_mysql_integer_not_null_defaults in test/cases/defaults_test.rb was
failing. This test relies on the connection being in strict mode. By
default a new connection is not in strict mode, but Active Record
automatically places it in strict mode.
ActiveSchemaTest overwrites the connection's #execute method in order to
prevent SQL statements from actually being executed. One of the
operations which is performed in ActiveSchema test is a #recreate_database.
Since 2088bf27981137a2c6c8b2f718f33b417b4045af, recreate_database on
mysql or mysql2 will trigger a reconnect.
Due to the implementation of the hacking of #execute in
ActiveSchemaTest, this reconnect would take place, but the connection
would *not* be placed in strict mode because #execute had been
overridden to prevent SQL queries hitting the database.
Therefore, after ActiveSchemaTest, the connection would no longer be in
strict mode, causing test_mysql_integer_not_null_defaults to fail.
I don't think that the way that ActiveSchemaTest is implemented is
particularly nice or clean, but I have taken steps to make its hacks
more isolated - it now create a separate connection object which is
thrown away after the test, and the hacks are applied on the singleton
class of this object.
|
|\ \ \
| | | |
| | | | |
Restore ActiveRecord connection to original environment after rake:db:test:prepare task.
|
| | | | |
|
|/ / /
| | |
| | |
| | | |
It is new in PostgreSQL-9.2 .
|
|/ /
| |
| |
| |
| |
| |
| | |
According to the doc of `AR::Base#to_param`(
https://github.com/rails/rails/blob/04cda1848cb847c2bdad0bfc12160dc8d554
7775/activerecord/lib/active_record/integration.rb#L18 ), it returns
`nil` if the record is not persisted.
|
|\ \
| | |
| | | |
Extract tests code out from AR's base_test.rb to integration_test.rb
|
| |/
| |
| |
| |
| |
| | |
`AR::Base#to_param` and `AR::Base#cache_key` is defined at
active_record/integration.rb, so tests for those methods should be at
integration_test.rb
|
|\ \
| | |
| | |
| | |
| | | |
chancancode/handle_aliased_attributes_in_ar_relation
Handle aliased attributes in AR::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')`.
Github #7839
*Godfrey Chan*
|
|/ /
| |
| |
| | |
Introduced in 09ac1776abc0d3482f491f2d49f47bcb3d9a4ad7.
|
|/
|
|
| |
without this, it's not possible to use UUID primary keys without uuid-ossp installed and activated
|
|\ |
|
| | |
|
| | |
|
| | |
|
| |
| |
| |
| |
| | |
Emphasizing that without autosave option only new
records are saved and updated records are not saved
|
| | |
|
| | |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
activerecord/lib/active_record/associations.rb states:
# [association=(associate)]
# Assigns the associate object, extracts the primary key, sets it as the foreign key,
# and saves the associate object.
Since commit 42dd5d9f2976677a4bf22347f2dde1a8135dfbb4 to fix #7191, this
is no longer the case if the associate has changed, but is the same
object. For example:
# Pirate has_one :ship
pirate = Pirate.create!(catchphrase: "A Pirate")
ship = pirate.build_ship(name: 'old name')
ship.save!
ship.name = 'new name'
pirate.ship = ship
That last line should trigger a save. Although we are not changing the
association, the associate (ship) has changed.
|
|\ \
| | |
| | | |
Added :nodoc: for relation.rb's private methods
|
| | | |
|
| | | |
|
|/ / |
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
|\ \
| | |
| | |
| | |
| | | |
jeremy/statement-invalid-wraps-underlying-exception
StatementInvalid takes WrappedDatabaseException's place
|
| | | |
|
|/ / |
|
|\ \
| | |
| | | |
Fix typo in serialized_attribute_test. [ci skip]
|
| | | |
|
|/ /
| |
| |
| | |
defined?(@attributes) in some places
|
| | |
|
| | |
|
| | |
|
| | |
|
|\ \
| | |
| | | |
Move method used only in the test to the test code itself
|
| | | |
|
|/ / |
|
|\ \ |
|
| | |
| | |
| | |
| | |
| | |
| | | |
It's simpler to assume that passed env is just a string without any
extensions, especially when DatabaseTasks are intended to be used also
without rails.
|
| | | |
|
| | | |
|
| | |
| | |
| | |
| | |
| | |
| | | |
This is a public class, which could be used directly in order to allow
easier database management. Now it also contains settings, which will be
used by databases.rake.
|
| | |
| | |
| | |
| | |
| | |
| | | |
This will allow to set fixtures path in global config easier, it should
be not needed to use FIXTURES_PATH every time user wants to load
fixtures.
|
| | | |
|