aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/relation
Commit message (Collapse)AuthorAgeFilesLines
* ActiveRecord::FinderMethods.find passes proc parameter #15382James Yang2014-06-101-1/+1
|
* Rename `type_cast` to `type_cast_from_database`Sean Griffin2014-06-091-2/+2
| | | | | | | | In some cases there is a difference between the two, we should always be doing one or the other. For convenience, `type_cast` is still a private method on type, so new types that do not need different behavior don't need to implement two methods, but it has been moved to private so it cannot be used accidentally.
* reuse available belongs_to? methodeileencodes2014-06-031-1/+1
| | | | | | | | | | Reflection has a `belongs_to?` method. Instead of checking for `macro == :belongs_to` throughout the source reuse existing method. I also bumped `foreign_key_present?` method onto on line because the `belongs_to?` makes it shorter than other longer lines in the same class.
* Remove unused `initialize_attributes` methodSean Griffin2014-06-021-1/+1
| | | | | This was previously a hook for a special case related to `serialize`, which has since been removed.
* Merge pull request #14834 from al2o3cr/issue14155Aaron Patterson2014-05-271-1/+10
|\ | | | | Correctly alias table names when joining more than once
| * WIP: pass existing joins to construct_join_dependencyMatt Jones2014-05-161-1/+10
| |
* | Allow empty arrays in where predicatesSean Griffin2014-05-261-0/+2
| |
* | Merge pull request #15300 from arthurnn/refactor_reflectionsRafael Mendonça França2014-05-262-3/+3
|\ \ | | | | | | Refactor reflections
| * | Merge pull request #15210 from arthurnn/fix_hbtm_reflectionArthur Neves2014-05-242-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | Fix habtm reflection Conflicts: activerecord/CHANGELOG.md activerecord/lib/active_record/counter_cache.rb activerecord/lib/active_record/reflection.rb activerecord/test/cases/reflection_test.rb
* | | Refactor the handling of arrays in where predicatesSean Griffin2014-05-261-11/+14
|/ / | | | | | | | | | | Simplifies the code slightly, isolates non-nil non-range values into a single array, which will make it easier to do things like apply type casting to them in the future.
* | Remove duplicated parameter check on #where!Sergey Alekseev2014-05-231-8/+4
| | | | | | | | | | | | | | | | | | | | It seems that #where! is not designed to be used as a chained where. See initial implementation at 8c2c60511beaad05a218e73c4918ab89fb1804f0. So, no need to check twice. We should not test #where! https://github.com/rails/rails/pull/15285#discussion_r13018316
* | Removed not-used codePaul Nikitochkin2014-05-221-1/+0
|/
* Merge pull request #15078 from nbudin/fix_merger_filter_binds_comparison_masterRafael Mendonça França2014-05-141-1/+1
|\ | | | | | | | | | | | | Make filter_binds filter out symbols that are equal to strings Conflicts: activerecord/CHANGELOG.md
| * Make filter_binds filter out symbols that are equal to stringsNat Budin2014-05-141-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | ActiveRecord::Relation::Merger's filter_binds method does not filter out bind variables when one of the attribute nodes has a string name, but the other has a symbol name, even when those names are actually equal. This can result in there being more bind variables than placeholders in the generated SQL. This is particularly an issue for PostgreSQL, where this is treated as an error. This patch changes the filter_binds method to make it convert both attribute names to strings before comparing.
* | docs, explain usage of `count` + `select`. Closes #15065. [ci skip]Yves Senn2014-05-131-0/+8
|/
* Put back Relation#join method as a delegate to ArrayBogdan Gusiev2014-05-051-1/+1
| | | | | | | | This is a regression 4.0 -> 4.1 fix. In 4.1.0 Relation#join is delegated to Arel#SelectManager. In 4.0 series it is delegated to Array#join This patch puts back the behaviour of 4.0
* push up bind params on "simple" subquery calculationsAaron Patterson2014-05-021-2/+4
| | | | | bind parameters we not being propogated to simple subquery calculation calls. This fixes it
* Give real privacy to class methods in AR::PredicateBuilderHector Satre2014-05-011-7/+8
|
* Merge branch 'master' into adequaterecordAaron Patterson2014-04-254-5/+25
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * master: (28 commits) move AR length validation tests into separate test-case. No need for trailing slash on migration path. reset `@arel` when modifying a Relation in place. PostgreSQL Timestamps always map to `:datetime`. [ci skip] Improve formatting and yml Fix a typo in the doc of forty_two AR FinderMethod Improve readability of contributing to rails guide. [ci skip] Precompile the image we're referencing, too. `ActiveRecord::Base.no_touching` no longer triggers callbacks or start empty transactions. Fixed an issue with migrating legacy json cookies. Correct comment [ci skip] Perfer to define methods instead of calling test Fix syntax error Add CHANGELOG entry for #14757 [ci skip] Fix run-on sentences and improve grammar [skip ci] Add test for using ActionView::Helpers::FormHelper.label with block and html select! renamed to avoid name collision Array#select! Rearrange deck chairs on the titanic. Organize connection handling test cases. Change favicon_link_tag helper mimetype from image/vnd.microsoft.icon to image/x-icon. ActionController::Renderers documentation fix ...
| * reset `@arel` when modifying a Relation in place.Yves Senn2014-04-241-0/+12
| | | | | | | | /cc @tenderlove
| * Fix a typo in the doc of forty_two AR FinderMethodEric Bouchut2014-04-241-1/+1
| |
| * Merge pull request #14757 from estsauver/14752Rafael Mendonça França2014-04-223-4/+12
| |\ | | | | | | Fix behavior of select! to be consistent with select #14752
| | * select! renamed to avoid name collision Array#select!Earl J St Sauver2014-04-213-4/+12
| | | | | | | | | | | | | | | | | | | | | | | | Fixes #14752 Select mimics the block interface of arrays, but does not mock the block interface for select!. This change moves the api to be a private method, _select!.
* | | Merge branch 'master' into adequaterecordAaron Patterson2014-04-201-1/+1
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * master: (74 commits) [ci skip] builtin -> built-in Fix code indentation and improve formatting Grammar fix in Getting Started Guide Make URL escaping more consistent Optimize URI escaping Always escape string passed to url helper. Remove statement assuming coffee shop/public space wifi is inherently insecure Don't rely on Arel master in bug report template [ci skip] wrap methods in backticks [ci skip] "subhash" --> "sub-hash" multibyte_conformance.rb --> multibyte_conformance_test.rb Fix inconsistent behavior from String#first/#last `@destroyed` should always be set to `false` when an object is duped. remove warning `warning: ambiguous first argument; put parentheses or even spaces` :uglify -> :uglifier Regression test for irregular inflection on has_many Singularize association names before camelization Fix spelling and proper nouns Optimize select_value, select_values, select_rows and dry up checking whether to exec with cache for Postgresql adapter Include default rails protect_from_forgery with: :exception ... Conflicts: activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb
| * | Make sure the column_name is different from 'all'.Lauro Caetano2014-04-141-1/+1
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 968c581ea34b5236af14805e6a77913b1cb36238 have fixed the EagerLoadTest, but not in the correct way. The problem was when `empty?` or `size` was called on relation. It was triggering `count(:all)`, which was passing `:all` as the column name to `count` on Calculations. On the other hand, the method `calculate` on Calculations was calling `construct_relation_for_association_calculations` instead of `perform_calculation`, because `has_include?` was returning `true` since `column_name` was present. To prevent calling the wrong method to perform the calculation, we have to check if the `column_name` is present and if it is different from `:all` (which is now used to correctly do `count` with `select`). More information here: https://github.com/rails/rails/commit/968c581ea34b5236af14805e6a77913b1cb36238#commitcomment-6006135
* | Merge branch 'master' into adequaterecordAaron Patterson2014-04-141-14/+22
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * master: (70 commits) [ci skip] Added link to ruby-lang.org installation. Use the index on hidden field `collection_check_boxes` respects `:index` option for the hidden filed name. docs, double meaning of `serialize` argument. Closes #14284. Just call read_attribute, no need to use `send`. - Fix lingering reference to `:text` instead of the newer `:plain` - Section references `form_tag` instead of the `form_for` used in the example again, read_attribute is public, so just call it read_attribute is public, so we should just call it Disable assest cache store in docs [ci skip] Make counter cache decrementation on destroy idempotent Write the failing test case for concurrent counter cache [ci skip] Use plain underscore instead of "\_". Update documentation to use Rails.application instead Add a changelog entry for #14546 [ci skip] Move tests for deep_dup and duplicable to object directory Missing 'are' in note - [ci skip] CollectionHelpers now accepts a readonly option Fix a few typos [ci skip] Bundle tzinfo-data on :x64_mingw (64-bit Ruby on Windows). don't bother with an offset if the offset is zero ...
| * don't bother with an offset if the offset is zeroAaron Patterson2014-04-121-6/+9
| | | | | | | | | | we're guaranteed to pass a numeric value for offset, so if it's zero, just don't add an offset to the query
| * only add the offset and index when we need toAaron Patterson2014-04-121-8/+9
| |
| * remove branching logic from calls to find_nthAaron Patterson2014-04-121-6/+10
| |
* | Merge branch 'master' into adequaterecordAaron Patterson2014-04-073-6/+9
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * master: (122 commits) Rails.application should be set inside before_configuration hook remove check for present? from delete_all Remove useless begin..end Build the reverse_order on its proper method. Use connection-specific bytea escaping Ignore order when doing count. make enums distinct per class Remove unused `subclass_controller_with_flash_type_bar` var from flash test. fix CollectionProxy delete_all documentation Added OS X specific commands to installation guide [ci skip] Recommended using homebrew for installing MySQL and PostgreSQL Fix setup of adding _flash_types test. Use SVG version of travis build status badge [skip ci] W3C CSP document moved to gihub.io URL [ci skip] sprockets-rails was released Fix the test defining the models in the right place Add CHANGELOG entry for #11650 [ci skip] Declare the assets dependency Use sass-rails 4.0.3 Make possible to use sprockets-rails 2.1 add missing parentheses to validates_with documentation [skip ci] ...
| * Build the reverse_order on its proper method.Lauro Caetano2014-04-072-4/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The reverse_order method was using a flag to control if the order should be reversed or not. Instead of using this variable just build the reverse order inside its proper method. This implementation was leading to an unexpected behavior when using reverse_order and then applying reorder(nil). Example: Before Post.order(:name).reverse_order.reorder(nil) # => SELECT "posts".* FROM "posts" ORDER BY "posts"."id" DESC After Post.order(:name).reverse_order.reorder(nil) # => SELECT "posts".* FROM "posts"
| * Ignore order when doing count.Lauro Caetano2014-04-071-1/+1
| | | | | | | | | | | | | | This is necessary because Postgresql doesn't play nice with ORDER BY and no GROUP BY. Fixes #14621.
| * Merge branch 'master' of github.com:rails/docrailsVijay Dev2014-03-291-1/+5
| |\
| | * Update documentation on group method to indicate it takes an arrayEarl St Sauver2014-03-171-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | The group method also takes an array, however this isn't immediately clear by reading the source since it delegates this method. If you trace it back to the AREL building you can see that it does support an array. Shoutout to @betovelandia for pointing this out.
| | * Fix misspelling in references docsSteven Harman2014-03-141-1/+1
| | |
* | | Merge branch 'master' into adequaterecordAaron Patterson2014-03-251-0/+2
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * master: (96 commits) clarify CHANGELOG [ci skip]. Fix Generation of proper migration when ActiveRecord::Base.pluralize_table_names = false. update comments to reflect that options support is not available synchronize changelogs and 4.1 release notes. [ci skip] do not rely on method_missing hitting arel use ARel factory methods for building AST nodes Fix date_select option overwriting html classes - Rename `increment_or_decrement` to an apt `set_cache_value` since it actually doesn't increment/decrement in localstore. Check if any sqlite files are not included in the gitignore Remove sqlite3 lines from .gitignore if the application is not using sqlite3. Adding active_model in Rails::Info Clean up tables after each test. Swapped parameters of assert_equal in assert_select Update test helper to use latest Digestor API Digestor should just rely on the finder to know about the format and the variant -- trying to pass it back in makes a mess of things (oh, and doesnt work) Log the full path, including variant, that the digestor is trying to find Fix for digestor to consider variants for partials -- this still needs more testing!! fix log_tags request object grammar Extract with_example_table into helper method. test for structure:dump without schema information table. refs eafec46 ... Conflicts: activerecord/test/cases/relation/where_chain_test.rb
| * | `where.not` adds `references` for `includes`.Yves Senn2014-03-171-0/+2
| | | | | | | | | | | | Closes #14406.
* | | Merge branch 'master' into adequaterecordAaron Patterson2014-03-131-2/+13
|\| | | | | | | | | | | | | | | | | * master: passing an instance of an AR object to `find` is deprecated passing an ActiveRecord object to `exists?` is deprecated.
| * | passing an instance of an AR object to `find` is deprecatedAaron Patterson2014-03-131-1/+5
| | | | | | | | | | | | please pass the id of the AR object by calling `.id` on the model first.
| * | passing an ActiveRecord object to `exists?` is deprecated.Aaron Patterson2014-03-131-1/+8
| |/ | | | | | | | | Pass the id of the object to the method by calling `.id` on the AR object.
* | `where` automatically uses bind values nowAaron Patterson2014-03-131-5/+2
| |
* | Merge branch 'master' into adequaterecordAaron Patterson2014-03-132-18/+28
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * master: (108 commits) make tests pass on Ruby 2.2 Use Sqlite3 adapter in examples use the body proxy to freeze headers just ask the response for the commit status, we do not need to ask the jar only write the jar if the response isn't committed Fix a grammatical error in the i18n guide [ci skip] use method_defined? to check whether or not a method is defined Enhance docs for update_attribute [ci-skip] Change usec to 0 on tests that compare seconds Unit test for mysql quote time usec Changelog entry for mysql56 microseconds Test microsecond on mysql 5.6 MySQL 5.6 and later supports microsecond precision in datetime. [ci skip] Add documentation for original_fullpath. Remove mocking on save, when not necessary comment why we are modifying global state. [ci skip] `change_table` supports `citext`. Follow up to #12523. Removed unnecessary command "application" register OID for PostgreSQL citex datatype [Troy Kruthoff & Lachlan Sylvester] Fixes STI when 2+ levels deep. ...
| * get rid of intermediate arrays.Yves Senn2014-03-051-2/+3
| | | | | | | | origin: https://github.com/rails/rails/commit/f6aeb8b1a3687c8523e4a56309fe3736011b2935#commitcomment-5569649
| * we only need to support `asc` and `ASC`. No need for mixed cases. #14263Yves Senn2014-03-051-13/+14
| | | | | | | | This is a result of the discussion at https://github.com/rails/rails/pull/14263/files#r10291489
| * Merge pull request #14263 from robin850/allow_passing_string_to_order_hashYves Senn2014-03-051-3/+6
| |\ | | | | | | Follow up of #10732 - Allow string hash values on AR order method
| | * Allow string hash values on AR order methodMarcelo Casiraghi2014-03-041-3/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | This behavior has almost no performance impact: String not allowed 66.910000 0.030000 66.940000 ( 67.024976) String allowed 69.360000 0.030000 69.390000 ( 69.503096) Benchmarked with http://git.io/Y0YuRw.
| * | Make exists? use bound values.Martin Schürrer2014-03-041-1/+6
| |/ | | | | | | | | | | | | | | | | | | | | When we build a query with an inline value that is a numeric (e.g. because it's out of range for an int4) PostgreSQL doesn't use an index on the column, since it's now comparing numerics and not int4s. This leads to a _very_ slow query. When we use bound parameters instead of inline values PostgreSQL raises numeric_value_out_of_range since no automatic coercion happens.
| * [ci skip] correct select examples and doc, ref [522c0fd]Kuldeep Aggarwal2014-03-011-4/+4
| |
* | Merge branch 'master' into adequaterecordAaron Patterson2014-02-171-5/+3
|\| | | | | | | | | | | | | | | | | | | * master: Revert "Merge pull request #13344 from ccutrer/fix-from-default-select" No need to use symbols Don't skip tests if they are not broken. Just don't define they Fix typo [ci skip] Resolve encoding issues with arrays of hstore (bug 11135). Fix coffeescript sample [ci skip]
| * Revert "Merge pull request #13344 from ccutrer/fix-from-default-select"Rafael Mendonça França2014-02-171-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit 3ea840355409dc205a9e0d027fc09f1452636969, reversing changes made to e4cde5d58cbb09d1843796f96ba86225ff94fe05. Conflicts: activerecord/CHANGELOG.md activerecord/lib/active_record/relation/query_methods.rb Reason: using `from` without `select` should not change the select list to SELECT * because it can lead different query results. If it is needed to change the table to a subquery or a view you can pass a table alias in the `from` call or use `select('subquery.*')`. Fixes #14049.