| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
| |
This patch addresses the difficulty of retrieving datetime fields. By default, the database holds a higher precision than the time as a String.
This issue is discussed at length at the following links:
- [#3519](https://github.com/rails/rails/issues/3519)
- [#3520](https://github.com/rails/rails/issues/3520)
Also, kudos to @mattscilipoti
|
|\
| |
| | |
Dynamic finders for aliased attributes
|
| |
| |
| |
| |
| | |
previously dynamic finders only worked in combination with the actual
column name and not its alias defined with #alias_attribute
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Ensure it works with mix of symbols and strings, and with a select
clause possibly containing more than one column.
Also remove support for pluck with an array of columns, in favor of
passing the list of attributes:
Model.pluck(:a, :b)
See comments: https://github.com/rails/rails/pull/6500#issuecomment-6030292
|
| | |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
When generating xml with a custom implementation of serializable_hash,
if using the :except option, it was being overriden by the default AR
implementation that attempts to ignore the inheritance column from STI
automatically. So, if you have an implementation like this:
def serializable_hash(options={})
super({ except: %w(some_attr) }.merge!(options))
end
The :except option was correctly being used for :json generation, but
not for :xml, because the options hash already contained the :except
key with the inheritance column, thus overriding the customization.
This commit fixes this problem by removing the :except logic from the
xml serializer, that happened before calling serializable_hash. Since
serializable_hash also does the same check for inheritance column, this
logic was duplicated in both places, thus it's safe to remove it from
xml serializer (see ActiveRecord::Serialization#serializable_hash).
This is an attempt to solve issue #2498, that claims for a
"Single transformation API for both xml and json representations".
|
| |
| |
| |
| |
| |
| | |
ActiveRecord json/xml serialization should use as base
serializable_hash, provided by ActiveModel. Add some more coverage
around options :only and :except for both json and xml serialization.
|
| | |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Improve the derivation of HABTM join table name to take account of nesting.
It now takes the table names of the two models, sorts them lexically and
then joins them, stripping any common prefix from the second table name.
Some examples:
Top level models
(Category <=> Product)
Old: categories_products
New: categories_products
Top level models with a global table_name_prefix
(Category <=> Product)
Old: site_categories_products
New: site_categories_products
Nested models in a module without a table_name_prefix method
(Admin::Category <=> Admin::Product)
Old: categories_products
New: categories_products
Nested models in a module with a table_name_prefix method
(Admin::Category <=> Admin::Product)
Old: categories_products
New: admin_categories_products
Nested models in a parent model
(Catalog::Category <=> Catalog::Product)
Old: categories_products
New: catalog_categories_products
Nested models in different parent models
(Catalog::Category <=> Content::Page)
Old: categories_pages
New: catalog_categories_content_pages
Also as part of this commit the validity checks for HABTM assocations have
been moved to ActiveRecord::Reflection One side effect of this is to move when
the exceptions are raised from the point of declaration to when the association
is built. This is consistant with other association validity checks.
|
| | |
|
|/ |
|
|\
| |
| | |
Refactor db:structure:load task.
|
| | |
|
| | |
|
|\ \
| |/
|/|
| | |
Fix GH #4259. When we execute schema dumper, we must remove table_name_prefix and table_name_suffix.
|
| |
| |
| |
| | |
we execute schema dumper.
|
| |
| |
| |
| | |
Also use if/else block to not use short circuit return
|
| |
| |
| |
| | |
Fix #5990
|
|\ \
| | |
| | | |
Refactor db:structure:dump task.
|
| | | |
|
|\ \ \
| | | |
| | | | |
Rename testcase name. It's wrong in the context.
|
| |/ / |
|
|/ / |
|
| |
| |
| |
| |
| | |
In a similar vein to Pat's work on create, drop etc, the db:charset
task is now a one liner in databases.rake
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
This happens when A has_many many B and A accepts_nested_attributes B that has a numeric colum
with initial 0 value. So a.update_attributes({:b_attributes => { :id => b.id, :numeric => 'foo' }})
passes the validation test but, the value of :numeric doesn't change.
his commit forces that the update fails with the above conditions.
Fixes #6393
Fixes #2331
|
| |
| |
| |
| |
| |
| | |
This allows you to retrieve the list of attributes you've defined.
Usable for e.g. selects in the view, or interators based on the
attributes you wish to store in the serialized column.
|
|\ \
| | |
| | |
| | | |
Removing composed_of
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
This feature adds a lot of complication to ActiveRecord for dubious
value. Let's talk about what it does currently:
class Customer < ActiveRecord::Base
composed_of :balance, :class_name => "Money", :mapping => %w(balance amount)
end
Instead, you can do something like this:
def balance
@balance ||= Money.new(value, currency)
end
def balance=(balance)
self[:value] = balance.value
self[:currency] = balance.currency
@balance = balance
end
Since that's fairly easy code to write, and doesn't need anything
extra from the framework, if you use composed_of today, you'll
have to add accessors/mutators like that.
Closes #1436
Closes #2084
Closes #3807
|
|/ /
| |
| |
| |
| | |
to avoid ORA-02289: sequence does not exist
for `SELECT "BLACK_JOKES_SEQ".NEXTVAL FROM dual`
|
| | |
|
| | |
|
|\ \
| | |
| | | |
Get logic out of db rake tasks, and into classes and objects
|
| | | |
|
| | | |
|
| | | |
|
| | | |
|
| | | |
|
| | | |
|
| | |
| | |
| | |
| | | |
Minimal implementation that supports db:create SQLite replacement
|
| | |
| | |
| | |
| | | |
config.active_record.mass_assignment_sanitizer=
|
| | | |
|
| | |
| | |
| | |
| | |
| | | |
Get rid of ActiveModel::Configuration, make better use of
ActiveSupport::Concern + class_attribute, etc.
|
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
Before 7f4b0a1231bf3c65db2ad4066da78c3da5ffb01, this test are asserting
that update_attribute does the dirty tracking. Since we remove this
method and update_column write in the database directly this tests will
always fail>
|
|\ \ \
| | | |
| | | |
| | | | |
Add uuid datatype support to PostgreSQL adapter
|
| | | | |
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
Historically, update_attribute and update_attributes are similar, but
with one big difference: update_attribute does not run validations.
These two methods are really easy to confuse given their similar
names. Therefore, update_attribute is being removed in favor of
update_column.
See the thread on rails-core here:
https://groups.google.com/forum/?fromgroups#!topic/rubyonrails-core/BWPUTK7WvYA
|
| | | | |
|
|\ \ \ \
| |/ / /
|/| | | |
Don't assign the attributes if the list is empty
|
| | | | |
|
| | | | |
|