Commit Graph

8252 Commits

Author SHA1 Message Date
Hrvoje Šimić 08a6b5753e move method for dependent option check 2012-08-01 11:33:12 -03:00
Franco Catena 3fb0100ef8 Fix string interpolation in belongs_to docs 2012-08-01 10:32:08 -03:00
Accessd db25ca7ec4 fix ActiveRecord::Associations::CollectionProxy documentation 2012-07-31 18:10:41 +04:00
Accessd 7dae39a743 fix typo in collection proxy 2012-07-31 17:37:33 +04:00
Bogdan Gusiev 92641efeec AR::Relation#order: make new order prepend old one
User.order("name asc").order("created_at desc")
    # SELECT * FROM users ORDER BY created_at desc, name asc

This also affects order defined in `default_scope` or any kind of associations.
2012-07-31 10:24:18 +03:00
Rafael Mendonça França 4ac81de52f Remove the deprecation of update_column.
update_column was suggested as replacement of update_attribute at the
last release of 3-2-stable, so deprecating it now will confuse the
users.
2012-07-30 10:50:18 -03:00
Francesco Rodriguez ea881ef996 update AR::Validations::AssociatedValidator documentation [ci skip] 2012-07-29 23:23:45 -05:00
Francesco Rodriguez 1cd40decd3 update AR::Validations::UniquenessValidator documentation [ci skip] 2012-07-29 23:20:27 -05:00
Aaron Patterson 0c315c75a4 Merge pull request #7196 from rimidl/fix-incorrect-require-mysql-in-mysql_rake_test
Fix incorrect usage `require mysql` in the activerecord/.../mysql_rake_test
2012-07-29 11:15:13 -07:00
Carlos Antonio da Silva 324ff46d36 Merge pull request #7188 from rodrigoflores/master
Documentation Fix: Pointing the case when no dependent option is given to a association method
2012-07-29 10:26:32 -07:00
Vladimir Strakhov 66529fc4d3 fix incorrect usage `require mysql` in the activerecord/test/.../mysql_rake_test.rb 2012-07-29 21:17:17 +04:00
Bogdan Gusiev fd0004b796 More polite cleanup for sqlite tests 2012-07-29 14:47:15 +03:00
Rodrigo Flores 915b6b3929 Explaining a bit better about the default behaviour of dependent 2012-07-28 23:13:46 -03:00
Xavier Noria 8bf1088d7d removes the AR session store from eager loaded code [fixes #7160]
See the comment in the file activerecord/lib/active_record.rb
added by this patch for the rationale.
2012-07-29 00:23:48 +02:00
Rafael Mendonça França ab0359c4ae Merge pull request #7185 from route/reset_table_name_refactoring
Refactor to reset_table_name
2012-07-28 09:18:38 -07:00
Xavier Noria 0cda0b3dba missing require: the AR session store depends on the AP abstract store
This require makes the dependency even more clear.
In particular we are eager loading the session
store but that does not work if AR is used
outside Rails, this patch is preliminary work
in fixing #7160.
2012-07-28 17:51:56 +02:00
Dmitry Vorotilin 8f4b54a13f Refactor to reset_table_name 2012-07-28 18:55:41 +04:00
Rafael Mendonça França 74262e654b Revert "Removed reference to composed_of."
This reverts commit c34c1916d1.

Reason: composed_of was added from now to discuss better
2012-07-27 19:36:44 -03:00
Rafael Mendonça França f4d818d51e Revert "Removing composed_of from ActiveRecord."
This reverts commit 14fc8b3452.

Reason: we need to discuss a better path from this removal.

Conflicts:
	activerecord/lib/active_record/reflection.rb
	activerecord/test/cases/base_test.rb
	activerecord/test/models/developer.rb
2012-07-27 19:25:14 -03:00
Yasuo Honda 708b5c0d3a Modity the :json_data_empty attribute from `:null => false` to `:null => true`
to address ORA-01400 errors with Oracle enhanced adapter.

The original commit 3c0bf043 requires :json_data_empty attribute
has empty string OR null, then setting `:default => ""` is enough.
2012-07-28 04:43:04 +09:00
José Valim 1fab518c6a Merge pull request #6827 from zephyr-dev/master
Validates_presence_of associated object marked for destruction
2012-07-27 11:02:29 -07:00
Jon Leighton 3205c768b7 Changelog and doc updates for the previous changes. 2012-07-27 18:08:18 +01:00
Jon Leighton d1099540af Deprecate Relation#all.
It has been moved to active_record_deprecated_finders.

Use #to_a instead.
2012-07-27 17:55:43 +01:00
Jon Leighton b658cf1198 Deprecate ActiveRecord::Base.scoped.
It doesn't serve much purpose now that ActiveRecord::Base.all returns a
Relation.

The code is moved to active_record_deprecated_finders.
2012-07-27 17:27:47 +01:00
Jon Leighton 6a81ccd69d ActiveRecord::Base.all returns a Relation.
Previously it returned an Array.

If you want an array, call e.g. `Post.to_a` rather than `Post.all`. This
is more explicit.

In most cases this should not break existing code, since
Relations use method_missing to delegate unknown methods to #to_a
anyway.
2012-07-27 13:34:12 +01:00
Rafael Mendonça França f1afd7765c Only require the `:rails_env` task where is needed.
`:rails_env` tasks is not needed in all the tasks that depends of
`load_config`, only in the tasks that uses `Rails.env`.

Since `:rails_env` task set the `Rails.env` to be "development" if it is
not set we don't need the `||` statements too

Fix #7175.

Conflicts:
	activerecord/lib/active_record/railties/databases.rake
2012-07-27 01:50:13 -03:00
Yasuo Honda dab8ca53be Modify the preference attribute from `:null => false` to `:null => true`
to address ORA-01400 errors with Oracle enhanced adapter.

Issue #4856 had been fixed and tested with
the attribute `:null => false, :default => ""`.
Now `:null => false` attribute is not necessary to test this issue.
2012-07-27 10:31:59 +09:00
beerlington d0aebd5357 Refactor ActiveRecord::Inheritance.base_class logic
Moved logic from class_of_active_record_descendant(class) to the
base_class method. This method was confusing because it required
an argument, but that argument was 'self'.

Moved base_class tests to inheritance_test.rb and added some test
coverage for some untested cases.
2012-07-26 13:46:49 -04:00
Dmitry Vorotilin 8cf300c906 Missed extend for eager_autoload 2012-07-26 14:04:32 +04:00
Jon Leighton 88c205ba53 Merge pull request #7166 from ayrton/patch-1
Update activerecord/CHANGELOG.md
2012-07-26 01:07:02 -07:00
Jon Leighton 07c455d94f Merge pull request #7161 from michaelfairley/eager_load_active_record_association_helpers
Eager autoload ActiveRecord association helpers
2012-07-26 01:05:17 -07:00
Ayrton De Craene c046a29a32 Update activerecord/CHANGELOG.md
Fixed markdown code indenting
2012-07-26 10:30:50 +03:00
Philip Arndt ffe8b0a36a Switched update_column recommendation in changelog to update_columns
Related to #7164

Looks like the last one; thanks!
2012-07-26 16:01:51 +12:00
Michael Fairley a052fc95a7 Eager autoload ActiveRecord association helpers 2012-07-25 17:34:39 -07:00
Aaron Patterson 0dc356e733 Merge pull request #6654 from stevecj/postgresql-auto-reconnect-2
Postgresql auto reconnect 2
2012-07-25 16:59:19 -07:00
Yasuo Honda 05895c6c86 Use string datatype for the setting attribute
to make store works all database adapters.
2012-07-26 02:19:23 +09:00
Rafael Mendonça França 2d9e5a26a1 Deprecate update_column in favor of update_columns.
Closes #1190
2012-07-24 20:20:26 -03:00
Rafael Mendonça França da84ccb6f0 Use update_columns to implemente the update_column 2012-07-24 20:15:48 -03:00
Sebastian Martinez 87ffc3662f New #update_columns method. 2012-07-24 19:06:22 -03:00
Yasuo Honda 0da49506f1 This pull requests addresses ORA-01400 errors and also supports #6115 issue tested.
Issue #6115 has been fixed and tested with
the attribute `:null => false, :default => ""`
However `:null => false` attribute is not necessary to test this issue,
which causes many ORA-01400 errors with Oracle enhanced adapter.
2012-07-25 03:51:23 +09:00
Seamus Abshere 5ca11fefce Make sure :environment task is executed before db:schema:load or db:structure:load
Otherwise, if schema_format = :sql, you will see:
$ rake db:setup --trace
** Invoke db:setup (first_time)
** Invoke db:schema:load_if_ruby (first_time)
** Invoke db:create (first_time)
** Invoke db:load_config (first_time)
** Invoke rails_env (first_time)
** Execute rails_env
** Execute db:load_config
** Execute db:create
db_example_development already exists
db_example_test already exists
** Execute db:schema:load_if_ruby       #<-------- :environment hasn't been executed yet
** Invoke db:schema:load (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:schema:load
~/db_example/db/schema.rb doesn't exist yet. Run `rake db:migrate` to create it then try again.
2012-07-23 17:33:00 -05:00
Steve Klabnik c34c1916d1 Removed reference to composed_of.
It was previously removed from the code, so we shouldn't mention
it in the docs
2012-07-23 04:13:18 -04:00
kennyj 8ca93c7883 Restore connection_id on error. 2012-07-23 00:46:00 +09:00
Vijay Dev dad5446a6c Merge branch 'master' of github.com:lifo/docrails 2012-07-21 21:50:14 +05:30
Vijay Dev 8fe5f01c31 improve NullRelation docs [ci skip] 2012-07-21 21:45:32 +05:30
Vijay Dev c851deff83 minor copy edits [ci skip] 2012-07-21 21:44:33 +05:30
Brent Wheeldon & Nick Monje 9feda92940 AR has a subclass of AM:PresenceValidator.
This allows us to mark the parent object as invalid if all associated objects
in a presence validated association are marked for destruction.

See: https://github.com/rails/rails/issues/6812
2012-07-20 17:37:57 -04:00
Jon Leighton 2f6e33d3f8 rm unnecessary test
interpolation is no longer a thing separate from "normal" assoc
conditions.
2012-07-20 19:35:02 +01:00
Jon Leighton f7d8aac40a rm redundant test
now everything is converted to the new style, this is not needed
2012-07-20 19:31:17 +01:00
Jon Leighton 45285f56f4 remove unused method 2012-07-20 19:18:12 +01:00
Jon Leighton ac48b62b27 we don't need this arg 2012-07-20 19:00:46 +01:00
Jon Leighton 3803fcce26 Remove :finder_sql, :counter_sql, :insert_sql, :delete_sql. 2012-07-20 19:00:46 +01:00
Jon Leighton 70a86c6e0a Remove obsolete line.
This code is broken (it should say association_scope.uniq_value rather
than options[:uniq]) but the tests still pass.

I think it is designed to uniq-ify associations using finder_sql.
However, I am about to remove that anyway.
2012-07-20 19:00:46 +01:00
Jon Leighton e1cfa6e070 Convert association macros to the new syntax 2012-07-20 14:14:51 +01:00
Jon Leighton 7a271a8e84 Avoid options ever being nil
This fixes active_record_deprecated_finders.
2012-07-20 13:33:49 +01:00
Oscar Del Ben 11d488dd7a Fix typos 2012-07-19 11:16:02 -07:00
Rafael Mendonça França fa3c84fabe Merge pull request #7078 from kennyj/logging_query_plan
Log query plan when we use count_by_sql method.
2012-07-19 08:06:15 -07:00
Carlos Antonio da Silva 2897bf1fd7 Create default join table name using a Symbol
Lets stick with a symbol in join table name, it was removed in
993e164365 and broke the build.
2012-07-19 09:05:58 -03:00
José Valim 24705014b8 Use attributes instead of table names in migration example 2012-07-19 09:05:54 +03:00
Aleksey Magusev 5a7d31913b Add fkey attributes to `join_table` migration generator 2012-07-19 00:24:21 +04:00
Dave Kroondyk ccf7cd05ad revert Default timestamps to non-null
Commit 3dbedd2 added NOT NULL constraints to timestamps.
Commit fcef728 started to revert this, but was incomplete.
With this commit, 3dbedd2 should be fully reverted and
timestamps will no longer default to NOT NULL.
2012-07-18 10:59:32 -04:00
José Valim e243a8a32e Update changelog for migration generator change 2012-07-18 09:47:52 +02:00
José Valim 58ccc9f6c5 Merge pull request #7028 from lexmag/join_table_indexes
Add indexes to create_join_table method
2012-07-18 00:16:39 -07:00
Oscar Del Ben 27014bbf51 Add nodocs to delegation module and docs for merge! 2012-07-17 16:21:22 -07:00
Oscar Del Ben 21123d3a7d Update batches docs 2012-07-17 16:10:27 -07:00
Oscar Del Ben 28e534136f Add nodoc to HashMerger and Merger 2012-07-17 16:04:52 -07:00
Oscar Del Ben 30bf42b3ef Fix typos and add nodocs to NullRelation 2012-07-17 15:53:36 -07:00
Oscar Del Ben 2c050e1808 Improve docs for AR Relation 2012-07-17 15:48:03 -07:00
John Firebaugh 80f61259f9 AR::Integration must be included after AM::Conversion
Integration's definition of #to_param must override
Conversion's. Otherwise, there is a regression from
3.1 in the behavior of a non-persisted AR::Base instance
which nevertheless has an id.
2012-07-17 15:16:43 -07:00
Aleksey Magusev 211d88b71b Add join table migration generator
For instance, running

    rails g migration CreateMediaJoinTable artists musics:uniq

will create a migration with

    create_join_table :artists, :musics do |t|
      # t.index [:artist_id, :music_id]
      t.index [:music_id, :artist_id], unique: true
    end
2012-07-18 00:13:19 +04:00
kennyj 1b25283943 Log query plan when we use count_by_sql method. 2012-07-18 03:02:11 +09:00
Aaron Patterson 939f014bdf Merge pull request #7076 from kennyj/fix_class_eval
Fix class_eval without __FILE__ and __LINE__.
2012-07-17 10:30:28 -07:00
kennyj 414008f98e Fix class_eval without __FILE__ and __LINE__. 2012-07-18 01:16:55 +09:00
beerlington 0c3c2279e7 Fixes "Cannot visit ..." with validates_uniqueness_of
Fixes issue with overrding ActiveRecord reader methods with a
composed object and using that attribute as the scope of a
validates_uniqueness_of validation.
2012-07-17 07:27:54 -04:00
Oscar Del Ben 5edbeb0a87 Add docs for Relation initialize, create and create! 2012-07-16 23:18:34 -07:00
Oscar Del Ben 9887440a0c Don't link to edgeguides in docs 2012-07-16 22:45:33 -07:00
Oscar Del Ben b64599a6c6 Typo 2012-07-16 12:36:52 -07:00
Oscar Del Ben 993ef9ed59 Add documentation for query_methods bang methods 2012-07-16 12:30:27 -07:00
Oscar Del Ben 37afdef536 Add nodoc to create_with_value
Reason: all *_value methods are defined dynamically and so don't appear
in the documentation.
2012-07-16 12:02:45 -07:00
Oscar Del Ben c0e186c155 Add documentation for arel and build_arel 2012-07-16 11:55:46 -07:00
Oscar Del Ben 97350762da Add documentation for create_with 2012-07-16 11:31:22 -07:00
Steve Jorgensen 4b1bca0402 Stop being silly with formatting of method aliasing. 2012-07-16 10:01:16 -07:00
Steve Jorgensen 6d5f4de4c4 Simulated & actual (manual/skipped) PostgreSQL auto-reconnection tests. 2012-07-16 09:55:20 -07:00
Steve Jorgensen 0d63cda2d7 Don't crash exception translation w/ nil result attribute.
Exception.result is nil when attempting a query after PostgreSQL
disconnect, resulting in new exception:
NoMethodError: undefined method `error_field' for nil:NilClass
2012-07-16 09:55:19 -07:00
Kang Wen 9c243b4bae Fix activerecord model to_ary method comment 'see also' link 2012-07-16 14:53:37 +08:00
Vijay Dev a80e1e437e Merge branch 'master' of github.com:lifo/docrails 2012-07-15 19:36:19 +05:30
kennyj 92dcdc590e session_id column is string in default 2012-07-15 02:56:08 +09:00
kennyj cd44862d72 Fix SqlBypass.data_column= problem. SqlBypass.find_by_session_id method didn't use this assignment. 2012-07-15 01:46:02 +09:00
kennyj 088022ef26 Avoid to call send(store_attribute) twice. 2012-07-15 00:04:30 +09:00
Aaron Patterson d08fee3f28 teaching the mysql adapter how to typecast strings returned from the database 2012-07-13 16:58:57 -07:00
Aaron Patterson 0736e169dc fixing tests to deal with data differences between prepared statements and non-prepared statements
Conflicts:
	activerecord/test/cases/query_cache_test.rb
2012-07-13 15:34:25 -07:00
Jeremy Cole 220864e2da Fixing texts; down to three failing tests.
Conflicts:
	activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb
2012-07-13 15:33:20 -07:00
Jeremy Cole 2f9a0f75db Only use prepared statements when bind variables are present
Prepared statements (prepare/execute/close) were being used unnecessarily
when no bind variables were present, and disabling prepared statement using
prepared_statements:false was principally broken. While bind variables were
correctly substituted with prepared_statements:false, the prepared statement
interface was still used, costing an extra two round trips per query.

In addition to making this behavioral change, I also cleaned up the internals
of exec_stmt and exec_without_stmt so that they behave the same (calling log
and constructing the ActiveRecord::Result in the same way).

Moving the check for binds.empty? to exec_query also will mean that several
code paths explicitly calling exec_without_stmt could be cleaned up to once
again call exec_query instead. I have also left the check for binds.empty? in
exec_stmt, since it is not a private method and could be called directly with
an empty binds array. For the sake of clarity in this patch, I have not made
those changes.

= The previous behavior =

When issuing a Foo.find(1) with prepared_statements:true, the bind variable
is present in the prepared query, and execute shows a value passed:

    Connect	root@localhost on rails_test
    Query	SET SQL_AUTO_IS_NULL=0
    Statistics
    Query	SHOW FULL FIELDS FROM `foos`
    Query	SHOW TABLES LIKE 'foos'
    Query	SHOW CREATE TABLE `foos`
    Prepare	SELECT  `foos`.* FROM `foos`  WHERE `foos`.`id` = ? LIMIT 1
    Execute	SELECT  `foos`.* FROM `foos`  WHERE `foos`.`id` = 1 LIMIT 1
    Close stmt
    Quit

When issuing a Foo.find(1) with prepared_statements:false, the bind variable
has already been removed and substituted with the value, but the prepared
statement interface is used anyway:

    Connect	root@localhost on rails_test
    Query	SET SQL_AUTO_IS_NULL=0
    Statistics
    Query	SHOW FULL FIELDS FROM `foos`
    Query	SHOW TABLES LIKE 'foos'
    Query	SHOW CREATE TABLE `foos`
    Prepare	SELECT  `foos`.* FROM `foos`  WHERE `foos`.`id` = 1 LIMIT 1
    Execute	SELECT  `foos`.* FROM `foos`  WHERE `foos`.`id` = 1 LIMIT 1
    Close stmt
    Quit

= With this patch applied =

When issuing a Foo.find(1) with prepared_statements:true, the bind variable
is present in the prepared query, and execute shows a value passed:

    Connect	root@localhost on rails_test
    Query	SET SQL_AUTO_IS_NULL=0
    Statistics
    Query	SHOW FULL FIELDS FROM `foos`
    Query	SHOW TABLES LIKE 'foos'
    Query	SHOW CREATE TABLE `foos`
    Prepare	SELECT  `foos`.* FROM `foos`  WHERE `foos`.`id` = ? LIMIT 1
    Execute	SELECT  `foos`.* FROM `foos`  WHERE `foos`.`id` = 1 LIMIT 1
    Close stmt
    Quit

When issuing a Foo.find(1) with prepared_statements:false, the bind variable
has been removed and substituted with the value, and the query interface is
used instead of the prepared statement interface:

    Connect	root@localhost on rails_test
    Query	SET SQL_AUTO_IS_NULL=0
    Statistics
    Query	SHOW FULL FIELDS FROM `foos`
    Query	SHOW TABLES LIKE 'foos'
    Query	SHOW CREATE TABLE `foos`
    Query	SELECT  `foos`.* FROM `foos`  WHERE `foos`.`id` = 1 LIMIT 1
    Quit
2012-07-13 15:32:28 -07:00
Jon Leighton 7fa9cb58c6 fix association :extend option 2012-07-13 21:20:26 +01:00
kennyj 87a86449e7 Remove duplicated unique index name. 2012-07-14 03:48:11 +09:00
kennyj 539b69e05d Remove instance level quote_value method. This method is private and also exists in class method. 2012-07-14 03:06:18 +09:00
Rafael Mendonça França fd9655c9dc Merge pull request #7045 from kennyj/remove_duplicated_code_20120714
Remove duplicated code in the AR::Store.
2012-07-13 10:58:54 -07:00
Xavier Noria bf6d64cd93 revises RUNNING_UNIT_TESTS to delegate stuff to the contributing guide 2012-07-13 19:56:11 +02:00
Jon Leighton ac4d101a75 move the deprecated options into active_record_deprecated_finders 2012-07-13 18:55:46 +01:00
Jon Leighton 09d2f168e6 stop using class_attribute where methods/inheritance will suffice. 2012-07-13 18:55:46 +01:00
kennyj 6c7c89a9f2 Remove duplicated code in the AR::Store. 2012-07-14 02:50:28 +09:00
Katrina Owen 7e5c6863f3 Add link to relevant rails guide to Active Record unit test docs. 2012-07-13 19:44:56 +02:00
Katrina Owen ec4245cfcb Add note about needing mysql superuser for unit tests. 2012-07-13 19:24:48 +02:00
Katrina Owen 848c1b4f47 Add documentation for ActiveRecord::Observer.
The instructions about configuration covered only rails-specific usage.
2012-07-13 18:58:29 +02:00
Jon Leighton 35edd185e1 extract deprecated association options to active_record_deprecated_finders 2012-07-13 17:40:26 +01:00
Jon Leighton 65843e1acc Represent association scope options as AR::Relations insternally. 2012-07-13 16:23:06 +01:00
Jon Leighton 76d3397061 fix assertion arguments order 2012-07-13 11:55:48 +01:00
Jon Leighton 5a54bffe37 Allow associations to take a lambda which builds the scope 2012-07-13 11:55:48 +01:00
Jon Leighton 4b4a85515b support relations created with a table alias 2012-07-13 11:44:45 +01:00
Robb Kidd 01fd8e57f3 Add teardown method to AR::Mig::RenameTableTest
Dry up reseting the renamed table after each test.

Also made use of the AR::Base.connection object already
available from AR::MigrationTest#connection.
2012-07-10 20:20:09 -04:00
Aaron Patterson d7b8f0c059 Merge pull request #6874 from robbkidd/rename_sequences_too
Rename default sequence when table is renamed? [AR:postgres]
2012-07-10 12:54:56 -07:00
Aleksey Magusev 0cae7c60ac Add references statements to migration generator
AddXXXToYYY/RemoveXXXFromYYY migrations are produced with references
statements, for instance

    rails g migration AddReferencesToProducts user:references
supplier:references{polymorphic}

will generate the migration with:

    add_reference :products, :user, index: true
    add_reference :products, :supplier, polymorphic: true, index: true
2012-07-08 23:03:05 +04:00
Oscar Del Ben e68f63e604 Add docs for having, lock and readonly 2012-07-07 13:53:38 -07:00
Oscar Del Ben 8e7470adcb Add doc for joins and improve includes doc 2012-07-07 11:36:03 -07:00
Oscar Del Ben 91c8d91536 Add docs for eager_laod and preload 2012-07-07 10:20:22 -07:00
Vijay Dev ee20be7c33 Merge branch 'master' of github.com:lifo/docrails 2012-07-07 20:44:49 +05:30
Vijay Dev 700e5ffea2 minor text change [ci skip] 2012-07-07 20:43:48 +05:30
Vijay Dev f7562c0c35 Revert "Add nodoc to relation methods"
This reverts commit c47a698d5d.

Reason: Let's revert pending further discussions
2012-07-07 20:42:22 +05:30
Carlos Antonio da Silva 5fde4d4793 Refactor locked? method in query cache
Introduced in 75b340d1a4
2012-07-07 11:29:15 -03:00
Jon Leighton d8ca791f48 Load all records in Relation#inspect
A test was failing due to the way that Relation#inspect causes
association proxies to ignore unsaved records added to the association.

This is fixed by simply calling to_a and letting to_a figure out how to
get the records (which, in the case of associations, takes into account
new records).

I think it is acceptable to do this rather than limiting the query at
the database level:

* It's what we've done in all released Rails versions up to this point
* The goal of the limit is to not flood the console with output - this
  is the problem we're targeting, rather than the actual loading of the
  records from the database
* You probably want to do something with those records later anyway,
  otherwise you wouldn't have built a relation for them.
2012-07-07 14:56:30 +01:00
Carlos Antonio da Silva 84b97813f6 Merge pull request #6838 from kennyj/added_registration_task
Allow to register database tasks from different adapters
2012-07-07 05:58:01 -07:00
Jon Leighton 90e42ff163 fixup changelog 2012-07-07 10:08:14 +01:00
Jon Leighton c433adffa2 Relation#inspect handles doesn't perform a new query on an already-loaded relation 2012-07-07 10:07:28 +01:00
Jon Leighton b76b9e2164 Simplify Relation#inspect 2012-07-07 09:58:56 +01:00
José Valim c55df9301c Merge pull request #6993 from morgoth/engine-table-name-prefix-generator-fix
Engine table name prefix generator fix
2012-07-07 00:57:01 -07:00
José Valim c7779c6fcd Merge pull request #6997 from kennyj/fix_stored_attributes
Added *instance_writer: false* to stored/serialized attributes.
2012-07-07 00:48:59 -07:00
kennyj 75322ac5b8 Added *instance_writer: false* for stored/serialized attributes. 2012-07-07 16:36:21 +09:00
Oscar Del Ben c47a698d5d Add nodoc to relation methods 2012-07-06 18:50:53 -07:00
Wojciech Wnętrzak 8fe9b43b30 Fixed generating namespaced table_name_prefix in engines 2012-07-06 21:22:53 +02:00
Damien Mathieu 7d0053e6a7 Limit the number of records in Relation#inspect
While it's interesting to have the results array, it can make a console or a webpage freeze if there are a lot of them.
So this limits the number of records displayed in #inspect to 10 and tells how much were effectively found.
2012-07-06 20:04:38 +02:00
Rafael Mendonça França 717aa92dd3 Merge pull request #6985 from sidonath/disable-query-cache-for-locks
Disable query cache for lock queries
2012-07-06 07:07:46 -07:00
Damir Zekic 75b340d1a4 Disable query cache for lock queries
Fixes #867
2012-07-06 15:01:55 +02:00
Carlos Antonio da Silva 48fe38201d Update release notes with AR::Relation#inspect change [ci skip]
See 07314e64fd.
Also fix some tabs in AR Changelog.
2012-07-06 08:57:59 -03:00
Jon Leighton 07314e64fd Show the records in Relation#inspect
The reason for removing the previous implementation of `#inspect` was
that it hid from you that you were dealing with a `Relation` rather than
an `Array`.

But it is still useful to be able to see the records, particularly if you're
writing something like the following in tests:

    assert_equal [foo], Post.where(:bar)

If the assertion fails, you want to see what records were actually
loaded.

So this implementation makes it clear that you've got a `Relation`, but
also shows your records.
2012-07-06 10:39:46 +01:00
Carlos Antonio da Silva 8ce61a3664 Merge pull request #6927 from parndt/patch-3
Make ArgumentError message more consistent in nested attributes
2012-07-05 20:06:29 -07:00
Philip Arndt a1ad02a4af Made ArgumentError messages consistent. 2012-07-06 14:31:33 +12:00
Oscar Del Ben ad919087a4 Add order docs 2012-07-05 19:02:58 -07:00
Oscar Del Ben d7a2309fe3 Add group documentation 2012-07-05 19:01:00 -07:00
Oscar Del Ben d203a0e0b4 Add documentation for includes 2012-07-05 18:43:48 -07:00
Vitor Balocco 2942192261 Add documentation for inheritance_column method 2012-07-05 18:59:42 +03:00
Francesco Rodriguez b5bb35355d fix quoting for ActiveSupport::Duration instances
This patch fixes quoting for ActiveSupport::Duration instances:

    # before
    >> ActiveRecord::Base.connection.quote 30.minutes
    => "'--- 1800\n...\n'"

    # after
    >> ActiveRecord::Base.connection.quote 30.minutes
    => "1800"

Also, adds a test for type casting ActiveSupport::Duration instances.

Related to #1119.
2012-07-04 22:39:16 -05:00
Aaron Patterson b7a4fe18f2 remove duplicate requires of mocha.
Mocha is already required by AS::TestCase, so remove the duplicate
requires.
2012-07-03 14:28:29 -07:00
Rafael Mendonça França 719ea779ea Don't need to use delete in the options hash 2012-07-03 13:25:26 -03:00
Aleksey Magusev 17d2115e3d Add changelog entry for references statements 2012-07-03 13:25:25 -03:00
Aleksey Magusev 68f0ef9056 Refactor references schema definitions 2012-07-03 13:25:25 -03:00
Aleksey Magusev 057fa33c3b Make references statements reversible 2012-07-03 13:25:25 -03:00
Aleksey Magusev cfb24586b8 Add references schema statements
Examples:

    add_reference :products, :supplier, polymorphic: true, index: true
    remove_reference :products, :user

`add_belongs_to` and `remove_belongs_to` are
acceptable.
2012-07-03 13:25:25 -03:00
kennyj 9196b93111 Don't mark the store as changed if an attribute isn't changed. 2012-07-03 12:19:31 +09:00
Carlos Antonio da Silva 215d41d802 Update 4.0 Release Notes with changelogs [ci skip]
Also fix some wrong formatting.

Related discussion:
ab72040b74 (commitcomment-1525256)
2012-07-02 22:34:51 -03:00
Francesco Rodriguez 62463d11b8 remove :nodoc: of AR::Scoping#unscoped [ci skip] 2012-07-01 15:53:27 -05:00