Commit Graph

6733 Commits

Author SHA1 Message Date
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
d80e4ee20e Regexp.union seems to have different results in 1.8 2011-12-08 10:20:14 -08:00
José Valim
06ac7d3ee0 Add performance scripts from wycats/rails-simple-benches to actionpack. 2011-12-08 16:39:06 +01:00
Jon Leighton
188b8c39da Fix broken test_exists_query_logging from the table_exists? change 2011-12-08 09:06:15 +00:00
Aaron Patterson
a505b13774 moving ignored regexp to the instance 2011-12-07 17:42:05 -08:00
Aaron Patterson
38a8f7f8ba speeding up ignored sql testing 2011-12-07 17:32:01 -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
Aaron Patterson
483a3cf287 automatically add the column definition to the columns list if creating a new one 2011-12-07 16:01:53 -08:00
Aaron Patterson
1fc47a1a84 stop calling String#to_s so frequently 2011-12-07 15:35:27 -08:00
Aaron Patterson
8523784265 the required sqlite3 adapter responds to encoding, so stop checking. 2011-12-07 15:01:04 -08:00
Evgeniy Kelyarsky
dd647d938e reversible migration example had missing block parameter 2011-12-07 17:03:51 +02:00
Aaron Patterson
9dee540084 avoid deprecated methods 2011-12-06 10:07:47 -08:00
Vasiliy Ermolovich
0968ee3456 add prefix and suffix to renamed tables, closes #1510 2011-12-06 10:02:45 -08:00
Aaron Patterson
8aa7b8695d Quitoting the table name before querying. 2011-12-05 14:20:14 -08:00
Jade Rubick
73a331c2ac Speed up table_exists? for databases with a large number of tables
At New Relic, we have hundreds of thousands of tables, and our migrations took 30 minutes without this similar patch. This cuts it down to a more reasonable amount of time.

The rescue false part is ugly, but necessary as far as I can tell. I don't know of a cross-database statement you can make that will work without trapping errors.
2011-12-05 11:20:10 -08:00
José Valim
cf6ccf0ebd Merge pull request #3854 from exviva/validates_associated_marked_for_destruction
Do not validate associated records marked for destruction
2011-12-04 15:57:13 -08:00
Olek Janiszewski
a8134aceb3 Do not validate associated records marked for destruction
The main reason for this change is to fix a bug where
`validates_associated` would prevent `accepts_nested_attributes_for`
with `allow_destroy: true` from destroying invalid associated records.
2011-12-05 00:19:21 +01:00
Jon Leighton
4ded0dd2de Merge pull request #3851 from ebeigarts/fix_sequence_name
Fix sequence name with abstract classes.
2011-12-04 15:19:17 -08:00
Xavier Noria
4e74bd194b moves some auto explain logic to the subscriber [José Valim & Xavier Noria] 2011-12-04 13:53:26 -08:00
Xavier Noria
7f3ce35e19 simplifies ActiveRecord::ExplainSubscriber [José Valim & Xavier Noria] 2011-12-04 13:27:03 -08:00
Xavier Noria
d59bfeb119 Merge branch 'explain' 2011-12-04 11:55:53 -08:00
Xavier Noria
cfeac38e2b implements a much faster auto EXPLAIN, closes #3843 [José Valim & Xavier Noria]
This commit vastly reduces the impact of auto
explain logging when enabled, while keeping
a negligible cost when disabled.

The first implementation was based on the idea
of subscribing to "sql.active_record" when
needed, and unsubscribing once done. This is
the idea behind AR::Relation#explain. Subscribe,
collect, unsubscribe.

But with the current implementation of notifications
unsubscribing is costly, because it wipes an internal
cache and that puts a penalty on the next event.

So we are switching to an approach where a long-running
subscriber is listening. Instead of collecting the
queries with a closure in a dedicated subscriber, now
we setup a thread local.

If the feature is disabled by setting the threshold
to nil, the subscriber will call a method that does
nothing. That's totally cheap.
2011-12-04 11:52:12 -08:00
Edgars Beigarts
82ae5c40ea Fix sequence name with abstract classes. 2011-12-04 20:10:14 +02:00
Carlos Antonio da Silva
4e836e4de9 Refactor readonly attributes conditional 2011-12-04 09:21:34 -02:00
Arun Agrawal
ac4763f5c0 SQlite3 Bump 2011-12-04 10:27:44 +05:30
Jon Leighton
e9b6659c4c Add missing require 2011-12-03 20:39:49 +00:00
Jon Leighton
51c2ef0b81 Avoid postgres 9.X syntax 2011-12-03 20:06:46 +00:00
Jon Leighton
9c172b2931 Fix #3837.
We also need to time zone convert time zone aware attributes when
accessed via read_attribute, not only when via direct access.
2011-12-03 16:46:46 +00:00
Xavier Noria
de24ed9f2d removes the convenience instance version of AR::Base.silence_auto_explain
Rationale: As discussed with José and Jon, this convenience
shortcut is not clearly justified and it could let the user
thing the disabled EXPLAINs are related to the model instance
rather than being globally disabled.
2011-12-03 14:26:34 +01:00
Jon Leighton
a02691ce09 Merge pull request #3820 from jaylevitt/nested_loading_through_assoc
reintroduce patch from #726 to handle nested eager loading via associations
2011-12-03 04:01:14 -08:00
Jon Leighton
2e902d52eb Merge pull request #3833 from kennyj/fix_3678-3
Use show create table (fix 3678: third time).
2011-12-03 03:36:00 -08:00