Commit Graph

2227 Commits

Author SHA1 Message Date
Jon Leighton
de2306f10c Merge pull request #4014 from lest/bypass-preloading-for-ids-reader
bypass preloading for ids_reader
2011-12-18 09:42:15 -08:00
Sergey Nartimov
109db5a550 bypass preloading for ids_reader
when fetching ids for a collection, bypass preloading
to avoid the unnecessary performance overhead
2011-12-18 10:59:24 +03:00
Sergey Nartimov
04cea56d89 call scope within unscoped to prevent duplication of where values 2011-12-17 14:41:17 +03:00
Jon Leighton
f307f4d884 Delete obsolete comment 2011-12-16 14:52:02 +00:00
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
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
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
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
8a37970312 Remove that there copy/pasted code 💣 2011-12-14 17:34:35 +00:00
Jon Leighton
909b337da8 Don't try to autosave nested assocs. Fixes #2961. 2011-12-14 17:28:59 +00:00
Jon Leighton
19bea9f1bd Stop the build asploding on 1.8.7 2011-12-14 15:31:12 +00:00
Jon Leighton
665ef116ac Add return for 1.8.7 2011-12-14 11:11:12 +00:00
Jon Leighton
3ab49f87e4 Unfluff the CI.
With transactional fixtures enabled, the session records would end up in
@_current_transaction_records, and at the end of the transaction,
methods would be called on them that would trigger method_missing and
trigger attribute methods to be generated.

However, at this point the sessions table would not exist, and the
columns were not cached, so an exception would be raised because we
can't find the columns to generate attribute methods for.

Not sure exactly why this didn't crop up before but there have been
changes to the schema cache code and perhaps that means that column data
that was cached previously at that point is now uncached.
2011-12-14 11:05:00 +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
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
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
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
Jon Leighton
5da90b3483 Fix #3890. (Calling proxy_association in scope chain.) 2011-12-08 20:10:04 +00:00
Aaron Patterson
d80e4ee20e Regexp.union seems to have different results in 1.8 2011-12-08 10:20:14 -08: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
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
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
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
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
Xavier Noria
0be5adaedf implements AR::Base(.|#)silence_auto_explain 2011-12-02 11:16:26 -08:00
Xavier Noria
0306f82e0c implements automatic EXPLAIN logging for slow queries 2011-12-02 04:35:43 -08:00
Jon Leighton
9ead4130de Create method with known identifier then alias into place.
This means we never have to rely on define_method (which is slower and
uses more memory), even when we have attributes containing characters
that are not allowed in standard method names.

(I am mainly changing this because the duplication annoys me, though.)
2011-12-01 23:41:51 +00:00
Jon Leighton
e9fb6d04bd Add test for read_attribute(:id) with non-standard PK.
Also make it actually work.

It slows down all read_attribute accesses to map 'id' to whatever the PK
actually is, inside read_attribute. So instead make sure the necessary
methods are defined and that they redirect wherever they need to go.
2011-12-01 23:41:51 +00:00
Jon Leighton
47b97a739d Fix up test altering global state that was causing me grief 2011-12-01 23:41:51 +00:00
Jon Leighton
3a40d38619 Get rid of the underscore versions of attribute methods!
This makes me happy!
2011-12-01 23:41:51 +00:00
Jon Leighton
52eedf5e2b Add hackery to make Syck use encode_with/init_with. Fixes 1.8 after recent changes to attribute serialization. 2011-12-01 01:15:16 +00:00