aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record
Commit message (Collapse)AuthorAgeFilesLines
* Merge pull request #21332 from ronakjangir47/take_docsEileen M. Uchitelle2015-08-231-0/+25
|\ | | | | Added docs for CollectionProxy#take
| * Added docs for CollectionProxy#take [ci skip]Ronak Jangir2015-08-231-0/+25
| |
* | Merge pull request #21335 from yui-knk/refactor/remove_not_used_block_argYves Senn2015-08-231-1/+1
|\ \ | |/ |/| Remove not used a block argument (`&block`)
| * Remove not used a block argument (`&block`)yui-knk2015-08-231-1/+1
| |
* | JSON is still an adapter specific type.Sean Griffin2015-08-218-36/+50
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Several changes were made in #21110 which I am strongly opposed to. (this is what I get for going on vacation. :trollface:) No type should be introduced into the generic `ActiveRecord::Type` namespace, and *certainly* should not be registered into the registry unconstrained unless it is supported by *all* adapters (which basically means that it was specified in the ANSI SQL standard). I do not think `# :nodoc:` ing the type is sufficient, as it still makes the code of Rails itself very unclear as to what the role of that class is. While I would argue that this shouldn't even be a super class, and that MySql and PG's JSON types are only superficially duplicated (they might look the same but will change for different reasons in the future). However, I don't feel strongly enough about it as a point of contention (and the biggest cost of harming the blameability has already occured), so I simply moved the superclass into a namespace where its role is absolutely clear. After this change, `attribute :foo, :json` will once again work with MySQL and PG, but not with Sqlite3 or any third party adapters. Unresolved questions -------------------- The types that and adapter publishes (at least those are unique to that adapter, and not adding additional behavior like `MysqlString` should probably be part of the adapter's public API. Should we standardize the namespace for these, and document them?
* better docs for `disable_ddl_transaction!`. Closes #21044.Yves Senn2015-08-211-1/+4
|
* Fix Punctuation in `AutosaveAssociation` RDocRobert Eshleman2015-08-201-2/+2
| | | | [ci skip]
* uniqueness validation raises error for persisted record without pk.Yves Senn2015-08-202-4/+9
| | | | | | | | Closes #21304. While we can validate uniqueness for record without primary key on creation, there is no way to exclude the current record when updating. (The update itself will need a primary key to work correctly).
* Merge pull request #21282 from sjain1107/added_docsYves Senn2015-08-191-0/+3
|\ | | | | | | Added docs for TableDefinition #coloumns & #remove_column [ci skip]
| * Added docs for TableDefinition #coloumns & #remove_column [ci skip]sjain11072015-08-181-0/+3
| |
* | Add a native JSON data type support in MySQLRyuta Kamizono2015-08-189-50/+76
| | | | | | | | | | | | | | | | | | | | As of MySQL 5.7.8, MySQL supports a native JSON data type. Example: create_table :json_data_type do |t| t.json :settings end
* | Merge pull request #21283 from ravindrakumawat/add_docs_for_pending_migrationYves Senn2015-08-181-0/+1
|\ \ | | | | | | Add Docs for ActiveRecord #check_pending [ci skip]
| * | Add Docs for ActiveRecord #check_pending [ci skip]ravindra kumar kumawat2015-08-181-0/+1
| | |
* | | Correct error message in Standard American english and add a test case for ↵prakash2015-08-181-1/+1
| |/ |/| | | | | the same.
* | Fix middleware deprecation message. Related to #21172.Jon Atack2015-08-141-1/+1
| |
* | Merge pull request #19683 from tristang/require-option-for-counter-cacheRafael Mendonça França2015-08-131-1/+8
|\ \ | | | | | | | | | Require explicit counter_cache option for has_many
| * | Require explicit counter_cache option for has_manyTristan Gamilis2015-04-071-1/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously has_many associations assumed a counter_cache was to be used based on the presence of an appropriately named column. This is inconsistent, since the inverse belongs_to association will not make this assumption. See issues #19042 #8446. This commit checks for the presence of the counter_cache key in the options of either the has_many or belongs_to association as well as ensuring that the *_count column is present.
* | | Merge pull request #19770 from vngrs/prevent_duplicated_where_clausesRafael Mendonça França2015-08-131-0/+1
|\ \ \ | | | | | | | | Prevent duplicating `where` clauses
| * | | Prevent duplicating `where` clauses when model is extended from an abstract ↵Mehmet Emin İNAÇ2015-04-151-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | class Fixes #19528 fix for mysql2 test better test
* | | | descriptive error message when fixtures contian a missing column.Yves Senn2015-08-131-2/+6
| | | | | | | | | | | | | | | | Closes #21201.
* | | | Skip statement cache on through association readerRafael Mendonça França2015-08-123-12/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | If the through class has default scopes we should skip the statement cache. Closes #20745.
* | | | Merge pull request #21210 from akihiro17/fix-rdoc-markupRafael Mendonça França2015-08-121-1/+1
|\ \ \ \ | | | | | | | | | | [ci skip] Fix rdoc markup
| * | | | [ci skip] Fix rdoc markupakihiro172015-08-121-1/+1
| | | | |
* | | | | docs, tiny rdoc markup fix. [ci skip]Yves Senn2015-08-121-1/+2
|/ / / / | | | | | | | | | | | | `+` doesn't work around content with spaces fallback `<tt>`.
* | | | Merge pull request #21205 from akihiro17/fix-docMatthew Draper2015-08-121-13/+13
|\ \ \ \ | | | | | | | | | | [ci skip] Fix the indentation
| * | | | [ci skip] Fix the indentationakihiro172015-08-121-13/+13
| | | | |
* | | | | Merge pull request #17885 from starbelly/patch-1Yves Senn2015-08-111-8/+20
|\ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add method to run command-line db apps Conflicts: activerecord/CHANGELOG.md
| * | | | | Add run_cmd class method to ActiveRecord::Tasks::DatabaseTasksstarbelly2015-08-012-11/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Added run_cmd() class method to dry up Kernel.system() messages within this namespace and avoid shell expansion by passing a list of arguments instead of a string - Update structure_dump, structure_load, and related tests units to pass a list of params instead of using a string to avoid shell expansion
* | | | | | Merge pull request #21165 from manlon/masterRafael Mendonça França2015-08-111-3/+7
|\ \ \ \ \ \ | |_|/ / / / |/| | | | | use correct DB connection for generated HABTM table
| * | | | | use correct DB connection for generated HABTM tableMatt Hanlon2015-08-071-3/+7
| | | | | |
* | | | | | Reference actual classesMiles Starkenburg2015-08-081-5/+5
| | | | | |
* | | | | | Remove XML Serialization from core.Zachary Scott2015-08-072-195/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This includes the following classes: - ActiveModel::Serializers::Xml - ActiveRecord::Serialization::XmlSerializer
* | | | | | Add ActiveRecord::Relation#in_batchesSina Siadat2015-08-074-10/+164
|/ / / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `in_batches` yields Relation objects if a block is given, otherwise it returns an instance of `BatchEnumerator`. The existing `find_each` and `find_in_batches` methods work with batches of records. The new API allows working with relation batches as well. Examples: Person.in_batches.each_record(&:party_all_night!) Person.in_batches.update_all(awesome: true) Person.in_batches.delete_all Person.in_batches.map do |relation| relation.delete_all sleep 10 # Throttles the delete queries end
* | | | | Merge pull request #20459Sean Griffin2015-08-061-0/+24
|\ \ \ \ \
| * | | | | Add missing data types for ActiveRecord migrationsMehmet Emin İNAÇ2015-06-081-0/+24
| | | | | |
* | | | | | Merge pull request #21092 from vngrs/use_memoization_for_ids_readerRafael Mendonça França2015-08-061-2/+4
|\ \ \ \ \ \ | | | | | | | | | | | | | | Use memoization for collection associations ids reader
| * | | | | | Use memoization for collection associations ids readerMehmet Emin İNAÇ2015-08-031-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixes #21082 remove extra space
* | | | | | | better docs for ActiveRecord::Migration#table_name_optionsBrendan Buckingham2015-08-061-1/+3
| | | | | | |
* | | | | | | Should use `server_info[:version]` instead of `info[:version]`Ryuta Kamizono2015-08-041-1/+1
|/ / / / / / | | | | | | | | | | | | | | | | | | | | | | | | Because `info[:version]` is a client version, the server version is `server_info[:version]`.
* | | | | | Fix test failures caused by #20884Sean Griffin2015-08-011-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | PostgreSQL is strict about the usage of `DISTINCT` and `ORDER BY`, which one of the tests demonstrated. The order clause is never going to be relevant in the query we're performing, so let's just remove it entirely.
* | | | | | Merge pull request #20884Sean Griffin2015-08-013-0/+56
|\ \ \ \ \ \ | |_|/ / / / |/| | | | | | | | | | | Add #cache_key to ActiveRecord::Relation.
| * | | | | Add #cache_key to ActiveRecord::Relation.Alberto F. Capel2015-07-203-0/+56
| | | | | |
* | | | | | Decrease string allocations on AR#respond_to?schneems2015-07-291-1/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When a symbol is passed in, we call `to_s` on it which allocates a string. The two hardcoded symbols that are used internally are `:to_partial_path` and `:to_model`. This change buys us 71,136 bytes of memory and 1,777 fewer objects per request.
* | | | | | Add `:nodoc:` for internal testing methods [ci skip]Robin Dupret2015-07-281-2/+2
| | | | | |
* | | | | | Merge pull request #20849 from vngrs/misleading_nested_exceptionsRafael Mendonça França2015-07-272-4/+24
|\ \ \ \ \ \ | | | | | | | | | | | | | | Fix misleading errors for has_one through relations
| * | | | | | Fix misleading errors for has_one through relationsMehmet Emin İNAÇ2015-07-222-4/+24
| | | | | | |
* | | | | | | Properly allow uniqueness validations on primary keys.Sean Griffin2015-07-251-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is an alternate implementation of #20966. [Sean Griffin & presskey]
* | | | | | | `destroy` shouldn't raise when child associations fail to saveSean Griffin2015-07-242-1/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Deep down in the association internals, we're calling `destroy!` rather than `destroy` when handling things like `dependent` or autosave association callbacks. Unfortunately, due to the structure of the code (e.g. it uses callbacks for everything), it's nearly impossible to pass whether to call `destroy` or `destroy!` down to where we actually need it. As such, we have to do some legwork to handle this. Since the callbacks are what actually raise the exception, we need to rescue it in `ActiveRecord::Callbacks`, rather than `ActiveRecord::Persistence` where it matters. (As an aside, if this code wasn't so callback heavy, it would handling this would likely be as simple as changing `destroy` to call `destroy!` instead of the other way around). Since we don't want to lose the exception when `destroy!` is called (in particular, we don't want the value of the `record` field to change to the parent class), we have to do some additional legwork to hold onto it where we can use it. Again, all of this is ugly and there is definitely a better way to do this. However, barring a much more significant re-architecting for what I consider to be a reletively minor improvement, I'm willing to take this small hit to the flow of this code (begrudgingly).
* | | | | | | Improvements on the enum documentation [ci skip]Robin Dupret2015-07-231-9/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The note regarding the `_prefix` and `_suffix` options is no longer useful since they were renamed specifically for this purpose. Also the given example doesn't show what these options enable and in which case they are really useful (when there are conflicting values for instance). Refs #20999. [Godfrey Chan & Robin Dupret]
* | | | | | | Rename the enum_{prefix,suffix} options to _{prefix,suffix}Robin Dupret2015-07-231-10/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This makes it more clear that they are reserved keywords and also it seems less redundant as the line already starts with the call to the `enum` method.