Commit Graph

5442 Commits

Author SHA1 Message Date
Jon Leighton
7b1eeea5bc Should clear the primary keys cache also 2011-12-16 13:52:07 +00:00
Jon Leighton
7f20bb995a Don't store defaults in the schema cache 2011-12-16 13:52:07 +00:00
Jon Leighton
dee94d8ab5 Defaults hash can go on the model 2011-12-16 13:52:07 +00:00
Jon Leighton
0b08ff7d92 Cache columns at the model level.
Allows two models to use the same table but have different primary keys.
2011-12-16 13:52:07 +00:00
José Valim
192e55c38e Do not raise an exception if an invalid route was generated automatically. 2011-12-16 10:45:59 +01:00
Jon Leighton
2b22564c4e Move DefaultScope and NamedScope under Scoping 2011-12-15 20:45:42 +00:00
Jon Leighton
17ad71e514 Let AttributeMethods do its own including etc 2011-12-15 20:45:42 +00:00
Jon Leighton
ceb33f8493 Split out most of the AR::Base code into separate modules 🍰 2011-12-15 20:45:37 +00:00
José Valim
8854bf29a3 Set up delegations also for to_a and arel branches. 2011-12-15 20:59:05 +01:00
José Valim
b17bc58c76 Move delegation reponsibilities of Relation to a module. Also precompile method missing calls for rofscale. 2011-12-15 20:47:26 +01:00
José Valim
1e8b751813 Make with_scope public so we stop using send 💣 2011-12-15 20:47:26 +01:00
José Valim
1af2a1d0f5 Improve delegate list to avoid method missing. 2011-12-15 20:01:56 +01:00
José Valim
283a087634 Clean up the cache before the request in case we are running in the reload_classes_only_on_change schema. 2011-12-15 18:48:10 +01:00
José Valim
de947c621d There isn't a column_hash. It was being invoked by method missing. 2011-12-15 17:09:48 +01:00
Jon Leighton
8dba32f125 Fix #3987. 2011-12-15 13:23:28 +00:00
Andrew Kaspick
774ff18c09 Allow nested attributes in associations to update values in it's owner object. Fixes a regression from 3.0.x 2011-12-14 20:13:03 -06:00
Jon Leighton
889e8bee82 Fix #3672 again (dependent: delete_all perf) 2011-12-14 19:20:19 +00:00
Jon Leighton
909b337da8 Don't try to autosave nested assocs. Fixes #2961. 2011-12-14 17:28:59 +00:00
Jon Leighton
18bf30982b Cache column defaults on model. ~30% on Model.new due to avoiding repeatedly fetching connection. 2011-12-14 16:14:47 +00:00
Jon Leighton
7b0edbb9f2 Avoid super; speeds up Model.new by about 12% 2011-12-14 16:14:47 +00:00
Jon Leighton
19bea9f1bd Stop the build asploding on 1.8.7 2011-12-14 15:31:12 +00:00
Jon Leighton
bb44e5a80a Use a separate module for 'external' attribute methods. 2011-12-14 14:51:57 +00:00
Jon Leighton
38703ac897 Revert naive O(1) table_exists? implementation.
It was a bad idea to rescue exceptions here. This can interfere with
transaction rollbacks which seems to be the cause of current CI
failure.

Instead, each adapter should implement its own DB-specific O(1)
implementation, and we fall back on the generic, slower, implementation
otherwise.
2011-12-13 23:46:26 +00:00
Vijay Dev
74e46e5156 Merge branch 'master' of github.com:lifo/docrails 2011-12-14 02:13:23 +05:30
José Valim
80256abb39 FileUpdateChecker should be able to handle deleted files. 2011-12-13 11:23:21 +01:00
Aaron Patterson
d12e6d0e2f use the schema cache when asking for the primary key 2011-12-12 15:59:44 -08:00
José Valim
fa1d9a884c Speed up development by only reloading classes if dependencies files changed.
This can be turned off by setting `config.reload_classes_only_on_change` to false.

Extensions like Active Record should add their respective files like db/schema.rb and db/structure.sql to `config.watchable_files` if they want their changes to affect classes reloading.

Thanks to https://github.com/paneq/active_reload and Pastorino for the inspiration. <3
2011-12-12 22:54:04 +01:00
clst
2be6df693a changed :finder_sql example to select *
because with select p.* you can no longer use count(). Using count will result in an SQL error message.
2011-12-12 18:27:51 +01:00
clst
a6b15bd2dc fixed example for :finder_sql
people.* will not work when the alias is named p
2011-12-12 15:46:42 +01:00
Aaron Patterson
d102791df7 ensure @fixture_connections is initialized in case an exception happens during setup 2011-12-10 16:33:08 -08:00
Aaron Patterson
d09b67cfc0 Errno::ENOENT error makes more sense when a file cannot be found 2011-12-10 16:32:07 -08:00
Piotr Sarnacki
35a1744a45 Allow to run migrations with given scope, with SCOPE=<scope>
Scope in migrations can be defined by adding suffix in filename,
like: 01_a_migration.blog.rb. Such migration have blog scope.

Scope is automatically added while copying migrations from engine,
so if you want to revert all of the migrations from given engine,
you can just run db:migrate with SCOPE, like:

    rake db:migrate SCOPE=blog
2011-12-09 22:00:51 +01:00
Piotr Sarnacki
f0b782d060 Allow to filter migrations by passing a block
Example:
  ActiveRecord::Migrator.migrate(path) do |migration|
    migration.name =~ /User/
  end

The above example will migrate only migrations with User in
the name
2011-12-09 21:43:36 +01:00
Aaron Patterson
5b82f50fef Use table_exists? from the schema cache. 2011-12-09 11:23:19 -08:00
Aaron Patterson
007965a651 don't need a begin / end. 2011-12-09 10:18:10 -08:00
Aaron Patterson
a29d1dbd59 squelch table exists? queries. 2011-12-09 10:14:49 -08:00
Piotr Sarnacki
929b2646b6 Compare migrations for copying only by name and scope 2011-12-09 12:15:54 +01:00
Piotr Sarnacki
ed0b1f6eed Add suffix for migrations copied from engines 2011-12-09 11:45:19 +01:00
Piotr Sarnacki
255d9f5ac1 String#to_a is not available in 1.9 2011-12-09 10:33:37 +01:00
Piotr Sarnacki
1d9de9d758 Run also migrations in subdirectories.
With this commit, ActiveRecord will also look for migrations
in db/migrate subdirectories.
2011-12-09 03:33:06 +01:00
Piotr Sarnacki
62d556424a Ignore origin comment when checking for duplicates on Migration.copy
49ebe51 fixed copying migrations, but existing migrations would still
trigger warnings. The proper way to compare migrations is to ignore
origin lines - if migration is identical it means that we can
silently skip it, regardless where it comes from.
2011-12-09 01:54:20 +01:00
Piotr Sarnacki
652db2fc3e Fix copying migrations from engines
There was a bug in ActiveRecord::Migration.copy method, which
prevented adding special comment about the origin of migration.

Because of that, the check if migration is identical or if it's
not and should be skipped was always saying that migration is
skipped, which was causing additional useless warnings about
skipped migrations.
2011-12-09 01:54:20 +01:00
Aaron Patterson
8c26cd5d97 Exceptions should read from the spec configu 2011-12-08 15:14:07 -08:00
Jon Leighton
5da90b3483 Fix #3890. (Calling proxy_association in scope chain.) 2011-12-08 20:10:04 +00:00
Vijay Dev
94dcbe8115 fix nodocs 2011-12-09 01:15:54 +05:30
Vijay Dev
965f6f22aa fix comments 2011-12-09 01:02:27 +05:30
José Valim
d1abf29e79 Remove NilClass whiners feature.
Removing this feature causes boost in performance when using Ruby 1.9.

Ruby 1.9 started to do implicit conversions using `to_ary` and `to_str`
in some STDLIB methods (like Array#join). To do such implicit conversions,
Ruby 1.9 always dispatches the method and rescues the NoMethodError exception
in case one is raised.

Therefore, since the whiners feature defined NilClass#method_missing, such
implicit conversions for nil became much, much slower. In fact, just defining
NilClass#method_missing (even without the whiners feature) already causes a
massive slow down. Here is a snippet that shows such slow down:

    require "benchmark"
    Benchmark.realtime { 1_000.times { [nil,nil,nil].join } }

    class NilClass
      def method_missing(*args)
        raise NoMethodError
      end
    end

    Benchmark.realtime { 1_000.times { [nil,nil,nil].join } }
2011-12-08 20:28:09 +01:00
Aaron Patterson
3cae753963 fixing eval'd line numbers. 2011-12-08 10:39:12 -08:00
Aaron Patterson
76c29a64b9 Use a hash to look up column definitions 2011-12-07 17:25:31 -08:00
Aaron Patterson
7e176a6d12 try to normalize the objects passed to column() 2011-12-07 16:18:39 -08:00