1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
Commit graph

30 commits

Author SHA1 Message Date
Sean Griffin
4a3cb840b0 Type#type_cast_from_database -> Type#deserialize 2015-02-17 13:28:48 -07:00
Sean Griffin
70d1b5a7f8 Revert "Improve performance of AR object instantiation"
This reverts commit 8fee923888.

Conflicts:
	activerecord/lib/active_record/attribute_set/builder.rb

This solution sucks, and is hard to actually apply across the board.
Going to try other solutions
2014-11-14 14:30:39 -07:00
Sean Griffin
8fee923888 Improve performance of AR object instantiation
We introduced a performance hit by adding an additional iteration
through a model's attributes on creation. We don't actually need the
values from `Result` to be a hash, we can separate the columns and
values and zip them up ourself during the iteration that we have to do.
2014-11-05 11:05:16 -07:00
Aaron Patterson
f0c2c6469f add length to ActiveRecord::Result 2014-10-13 12:01:41 -07:00
Sean Griffin
c083ce6dd2 Encapsulate knowledge of type objects on ActiveRecord::Result
Attempting to reduce the number of places that care about the details of
how type casting occurs. We remove the type casting of the primary key
in `JoinDependecy`, rather than encapsulating it. It was originally
added for consistency with
40898c8c19 (diff-06059df8d3dee3101718fb2c01151ad0R211),
but that conditional was later removed in
d7ddaa530f.

What is important is that the same row twice will have the same value
for the primary key, which it will.
2014-06-22 09:00:15 -06:00
Sean Griffin
6f08db05c0 Introduce an Attribute object to handle the type casting dance
There's a lot more that can be moved to these, but this felt like a good
place to introduce the object. Plans are:

- Remove all knowledge of type casting from the columns, beyond a
  reference to the cast_type
- Move type_cast_for_database to these objects
- Potentially make them mutable, introduce a state machine, and have
  dirty checking handled here as well
- Move `attribute`, `decorate_attribute`, and anything else that
  modifies types to mess with this object, not the columns hash
- Introduce a collection object to manage these, reduce allocations, and
  not require serializing the types
2014-06-13 10:20:54 -06:00
Sean Griffin
2742162072 Use an actual identity type in AR::Result#identity_type
We should be able to rely on this object implenting the full type
interface.
2014-06-09 13:28:26 -06:00
Sean Griffin
eb6cee9cf7 Rename attribute related instance variables to better express intent
`@attributes` was actually used for `_before_type_cast` and friends,
while `@attributes_cache` is the type cast version (and caching is the
wrong word there, but I'm working on removing the conditionals around
that). I opted for `@raw_attributes`, because `_before_type_cast` is
also semantically misleading. The values in said hash are in the state
given by the form builder or database, so raw seemed to be a good word.
2014-05-30 09:05:18 -07:00
Marc-Andre Lafortune
13d2696c10 Return sized enumerator from Batches#find_each 2014-02-05 16:53:02 -05:00
Vipul A M
f511eac2c1 Also dup column_types in AR::Result initialize_copy 2013-11-10 00:25:57 +05:30
Aaron Patterson
40898c8c19 typecast records returned from the db rather than to_sing everything 2013-10-08 10:49:53 -07:00
Sam
ba0568e46d Perf: micro optimised Result column hash_row creation 2013-08-29 14:06:24 +10:00
kennyj
dc1239d965 Added some usage about ActiveRecord::Result [ci skip] 2013-07-23 02:20:28 +09:00
Aaron Patterson
6cd8e3f58e make the identity type a singleton to save on object creation 2013-07-01 18:00:52 -07:00
Ben Woosley
d6cfbaea72 Change Result#each to return an Enumerator when called without a block.
As with #10992, this lets us call #with_index, etc on the results.
2013-06-18 15:34:18 -07:00
Jon Leighton
9e4c41c903 Remove ActiveRecord::Model
In the end I think the pain of implementing this seamlessly was not
worth the gain provided.

The intention was that it would allow plain ruby objects that might not
live in your main application to be subclassed and have persistence
mixed in. But I've decided that the benefit of doing that is not worth
the amount of complexity that the implementation introduced.
2012-10-26 15:51:02 +01:00
Santiago Pastorino
da400fbb0b Freeze columns only once per Result 2012-09-20 12:59:33 -03:00
Santiago Pastorino
2068d30091 Freeze columns just before using them as hash keys 2012-09-20 01:43:43 -03:00
Jeremy Evans
3aef5ce9b3 Freeze columns before using them as hash keys
This reduces the number of allocated strings from columns * (rows + 1) to just columns.
2012-09-13 14:13:19 -07:00
kennyj
5e47ba0a85 Refactor AR::Result or inherits. Because we have redundant codes about 2012-08-22 01:23:40 +09:00
Rob Zolkos
89fff791fa Doc for ActiveRecord::Result empty? method 2012-05-07 21:43:05 +10:00
Aaron Patterson
00b62ab73b moving column types to an ivar on the result 2012-02-07 13:51:53 -08:00
Aaron Patterson
9bcb9cd55f column types are passed from the result set to the instantiated AR object 2012-02-07 13:51:52 -08:00
Aaron Patterson
d6e41f364a QueryCache will just dup an AR::Result, AR::Result can deep copy 2012-01-31 10:59:50 -08:00
Aaron Patterson
40ce682048 made the result set object act more like an array 2012-01-31 10:58:16 -08:00
Sebastian Martinez
0034b7822d Remove extra white spaces on ActiveRecord docs. 2011-05-23 20:58:25 -03:00
Aaron Patterson
4c30304e15 updating the docco for ActiveRecord::Result 2011-04-11 10:10:01 -07:00
Aaron Patterson
59f7780a34 adjust query counts to be consistent across databases, make sure database log the same things 2011-02-04 18:14:59 -08:00
Aaron Patterson
9731c862ec AR internals expect a normal hash, otherwise there are serialization incompatibilities 2011-01-05 13:50:08 -08:00
Aaron Patterson
cc468d3ec8 exec returns an AR::Result 2010-10-26 13:44:07 -07:00