1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/activerecord/lib/active_record/relation
Sean Griffin 70ac072976 Attribute assignment and type casting has nothing to do with columns
It's finally finished!!!!!!! The reason the Attributes API was kept
private in 4.2 was due to some publicly visible implementation details.
It was previously implemented by overloading `columns` and
`columns_hash`, to make them return column objects which were modified
with the attribute information.

This meant that those methods LIED! We didn't change the database
schema. We changed the attribute information on the class. That is
wrong! It should be the other way around, where schema loading just
calls the attributes API for you. And now it does!

Yes, this means that there is nothing that happens in automatic schema
loading that you couldn't manually do yourself. (There's still some
funky cases where we hit the connection adapter that I need to handle,
before we can turn off automatic schema detection entirely.)

There were a few weird test failures caused by this that had to be
fixed. The main source came from the fact that the attribute methods are
now defined in terms of `attribute_names`, which has a clause like
`return [] unless table_exists?`. I don't *think* this is an issue,
since the only place this caused failures were in a fake adapter which
didn't override `table_exists?`.

Additionally, there were a few cases where tests were failing because a
migration was run, but the model was not reloaded. I'm not sure why
these started failing from this change, I might need to clear an
additional cache in `reload_schema_from_cache`. Again, since this is not
normal usage, and it's expected that `reset_column_information` will be
called after the table is modified, I don't think it's a problem.

Still, test failures that were unrelated to the change are worrying, and
I need to dig into them further.

Finally, I spent a lot of time debugging issues with the mutex used in
`define_attribute_methods`. I think we can just remove that method
entirely, and define the attribute methods *manually* in the call to
`define_attribute`, which would simplify the code *tremendously*.

Ok. now to make this damn thing public, and work on moving it up to
Active Model.
2015-01-31 19:42:38 -07:00
..
predicate_builder Remove unneeded requires 2015-01-04 12:11:03 -03:00
batches.rb
calculations.rb Attribute assignment and type casting has nothing to do with columns 2015-01-31 19:42:38 -07:00
delegation.rb Remove unneeded require 'as/deprecation' 2015-01-04 07:45:07 -08:00
finder_methods.rb Remove Relation#bind_params 2015-01-27 16:10:03 -07:00
from_clause.rb Use an Attribute object to represent a bind value 2015-01-27 12:07:06 -07:00
merger.rb Move the from bind logic to a FromClause class 2015-01-26 16:36:14 -07:00
predicate_builder.rb Remove Relation#bind_params 2015-01-27 16:10:03 -07:00
query_attribute.rb Remove Relation#bind_params 2015-01-27 16:10:03 -07:00
query_methods.rb Fixed AR::Relation#group method when argument is a SQL reserved keyword 2015-01-29 17:27:02 +02:00
spawn_methods.rb Remove references to :bind in except 2015-01-25 16:40:23 -07:00
where_clause.rb Post.all.or(anything) == Post.all 2015-01-29 13:57:47 -07:00
where_clause_factory.rb Move the construction of WhereClause objects out of Relation 2015-01-25 16:53:46 -07:00