Commit Graph

3574 Commits

Author SHA1 Message Date
Stevie Graham
83ecd03e7d use instance_eval, reduce method calls.
execution time in seconds for `rake test_sqlite3`:

ruby 1.9.2p0 (2010-08-18 revision 29036) [x86_64-darwin10.4.0]
  - before: 52.771426, 52.159505, 52.937056
  - after: 51.452584, 51.897017, 51.584431

rubinius 1.0.1 (1.8.7 release 2010-06-03 JI) [x86_64-apple-darwin10.4.0]
  - before: 284.334076
  - after: 285.753028

ruby 1.8.7 (2009-06-12 patchlevel 174) [universal-darwin10.0]
  - before: 75.811548, 75.533153, 75.353122
  - after: 75.244243, 75.19226, 75.256925
2010-09-21 01:44:29 +08:00
Piotr Sarnacki
d475de7e25 Add helper for loading seed data for engine and application
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-09-20 10:41:05 +02:00
Thiago Pradi
3c9bf6e1dc Exception handling more readable
[#5601 state:committed]

Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2010-09-19 12:18:51 -07:00
Xavier Noria
2b6c2e947b adds to the API guidelines the proper spelling of Arel 2010-09-19 00:05:05 +02:00
Tim Connor
37de59eacf Fix issue with remove_index and add unit test [#5645 state:resolved] 2010-09-18 20:49:31 +02:00
Tim Connor
55d0d57bfc Raise errors when index creation fails 2010-09-18 20:49:28 +02:00
Aaron Patterson
55736ef125 @join_values is passed in, so we should use the parameter 2010-09-15 14:18:15 -07:00
Aaron Patterson
ac9c715947 passing the quoted id to arel if the object has a quoted id 2010-09-10 15:28:57 -07:00
Aaron Patterson
13aa1e11a0 converting an inject to a map + Hash[] 2010-09-10 15:28:57 -07:00
Aaron Patterson
a8b4bdb3d6 avoid method_missing and reduce method calls 2010-09-10 10:22:22 -07:00
Marcelo Giorgi
a513f8f8bb intersection between a relation and an array works in both directions
Signed-off-by: Mikel Lindsaar <raasdnil@gmail.com>
2010-09-10 21:14:07 +10:00
Jeremy Kemper
e0e3adff03 Cheaper attribute reads and respond_to?. Add underscore-prefixed method aliased to the attribute name so it can be overridden but still called internally. 2010-09-09 14:39:43 -07:00
Jeremy Kemper
4b7b8d9e19 Cache unserialized attributes 2010-09-09 14:37:57 -07:00
Emilio Tagua
53a90436cf Refactor finder conditions look up and assigment for apply_finder_conditions. 2010-09-09 13:45:49 -07:00
Emilio Tagua
90c114de67 Refactor Relation#only. No need to go through every option and test it. 2010-09-09 15:30:44 -03:00
Emilio Tagua
33412b6e16 No need to go through every option and test it, just don't add skipped ones. 2010-09-09 15:16:45 -03:00
Neeraj Singh
632120deb4 return is not needed here 2010-09-09 10:34:20 -07:00
Neeraj Singh
2f66b9a76c remove unnecessary call
if operation is count then column_name will never be blank
2010-09-09 10:33:52 -07:00
Aaron Patterson
be07d7b107 creating a new array is required. who knew? :-( 2010-09-09 10:33:22 -07:00
Aaron Patterson
a505c82d2f no need for Array.wrap, also avoid array creation 2010-09-09 09:44:01 -07:00
Neeraj Singh
d5c57f7c9f make apply_modules run faster 2010-09-09 09:35:40 -07:00
Aaron Patterson
03377c755f eliminate present? for fewer method calls 2010-09-08 16:56:13 -07:00
Aaron Patterson
b4fdfcf6ad returning arrays lets us avoid Array.wrap 2010-09-08 16:53:17 -07:00
Aaron Patterson
588db0fa8f removing unnecessary conditional test 2010-09-08 16:38:54 -07:00
Aaron Patterson
0db345a39d switch to blank? to avoid method calls 2010-09-08 16:33:16 -07:00
Aaron Patterson
cb1f80591e refactor to use faster empty? 2010-09-08 16:06:48 -07:00
Aaron Patterson
4ccf491ec2 drying up joins() 2010-09-08 15:34:03 -07:00
Aaron Patterson
86384b3c4b reduce method calls, use reject + blank? instead of select + present? 2010-09-08 15:15:06 -07:00
Aaron Patterson
2faa8bbe11 refactor a couple injects to map + Hash[] 2010-09-08 14:02:47 -07:00
Aaron Patterson
c0c8a04efc avoid an inject in favor of dup 2010-09-08 13:55:30 -07:00
Aaron Patterson
a5d894ce56 attributes should be constructed with table objects 2010-09-07 16:47:10 -07:00
Aaron Patterson
0c7a4daaa1 attributes should be associated with tables 2010-09-07 16:38:49 -07:00
Aaron Patterson
c6015cbcd8 serialized attributes should be serialized before validation [#5525 state:resolved] 2010-09-07 13:39:27 -07:00
Aaron Patterson
c8a2dd3cac no need to freeze this string 2010-09-07 13:13:13 -07:00
Jakub Suder
2524cf404c fixed some issues with JSON encoding
- as_json in ActiveModel should return a hash
  and handle :only/:except/:methods options
- Array and Hash should call as_json on their elements
- json methods should not modify options argument

[#5374 state:committed]

Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
2010-09-07 11:33:10 -07:00
Aaron Patterson
2e8a3d0f43 removing useless code, cleaning variable names 2010-09-07 11:28:01 -07:00
Aaron Patterson
604281221c select should raise error when no block or no parameter is passed 2010-09-07 10:48:14 -07:00
Aaron Patterson
d00f1c18eb select does not need a *args 2010-09-07 10:33:20 -07:00
Santiago Pastorino
e8c7f1af0f unscoped has nothing so merging with a relation just returns the relation 2010-09-07 03:33:06 -03:00
Aaron Patterson
b541a963bd cleaning up confusing logic 2010-09-06 18:56:16 -07:00
Piotr Sarnacki
7c78cc3cca Use railties:copy_migrations instead of db:copy_migrations
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-09-06 14:38:45 +02:00
Carlos Antonio da Silva
ed2650646e Refactor AR validations a bit
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-09-06 13:40:06 +02:00
Carlos Antonio da Silva
9b610049bb Cleanup deprecation warnings in active record
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-09-06 13:39:55 +02:00
Pratik Naik
3bd3e992ff Improved indentation 2010-09-06 11:54:02 +01:00
Santiago Pastorino
0a7b481903 Use scoped here to get the scoped where 2010-09-05 20:30:43 -03:00
Santiago Pastorino
708ee9c5ac Make scoped reorder override previous applied orders
[5528 state:committed]
2010-09-05 08:28:11 -03:00
Neeraj Singh
91fec0d24d order should always be concatenated.
order that is declared first has highest priority in all cases.

Here are some examples.

Car.order('name desc').find(:first, :order => 'id').name

Car.named_scope_with_order.named_scope_with_another_order

Car.order('id DESC').scoping do
  Car.find(:first, :order => 'id asc')
end

No special treatment to with_scope or scoping.

Also note that if default_scope declares an order then the order
declared in default_scope has the highest priority unless
with_exclusive_scope is used.

Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2010-09-05 08:13:42 -03:00
Piotr Sarnacki
e063879daf Fix copying migrations to empty directory 2010-09-03 22:59:10 +02:00
Piotr Sarnacki
43a2aef316 rake db:copy_migrations task, which copies railties migrations into application's db/migrate directory 2010-09-03 22:59:09 +02:00
Piotr Sarnacki
75f8ac6ea7 Implemented ActiveRecord::Migrations#copy based on James Adam's idea
ActiveRecord::Migration#copy allows to copy migrations from one place
to another, changing migrations versions and adding scope to filename.

For example:
ActiveRecord::Migration.copy("db/migrate",
        :blog_engine => "vendor/gems/blog/db/migrate")

will copy all migrations from vendor/gems/blog/db/migrate to db/migrate
with such format:

Versions of copied migrations will be reversioned to be appended after
migrations that already exists in db/migrate
2010-09-03 22:59:09 +02:00