| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
| |
|
|\
| |
| |
| |
| |
| |
| | |
Changed ActiveRecord::Relation#update behavior so that it will work on Relation objects without giving id
Conflicts:
activerecord/CHANGELOG.md
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
callbacks and validations
- Right now, there is no method to update multiple records with
validations and callbacks.
- Changed the behavior of existing `update` method so that when `id`
attribute is not given and the method is called on an `Relation`
object, it will execute update for every record of the `Relation` and
will run validations and callbacks for every record.
- Added test case for validating that the callbacks run when `update` is
called on a `Relation`.
- Changed test_create_columns_not_equal_attributes test from
persistence_test to include author_name column on topics table as it
it used in before_update callback.
- This change introduces performance issues when a large number of
records are to be updated because it runs UPDATE query for every
record of the result. The `update_all` method can be used in that case
if callbacks are not required because it will only run single UPDATE
for all the records.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
This class cares far too much about the internals of other parts of
Active Record. This is an attempt to break out a meaningful object which
represents the needs of the predicate builder. I'm not fully satisfied
with the name, but the general concept is an object which represents a
table, the associations to/from that table, and the types associated
with it. Many of these exist at the `ActiveRecord::Base` class level,
not as properties of the table itself, hence the need for another
object. Currently it provides these by holding a reference to the class,
but that will likely change in the future. This allows the predicate
builder to remain wholy concerned with building predicates.
/cc @mrgilman
|
|/
|
|
|
|
|
| |
Construction of relations can be a hotspot, we don't want to create one
of these in the constructor. This also allows us to do more expensive
things in the predicate builder's constructor, since it's created once
per AR::Base subclass
|
|
|
|
| |
Users should pass strings to queries instead of classes
|
| |
|
|
|
|
|
|
| |
Arel handles this for us automatically. Updated tests, as BindParam is
no longer a subclass of SqlLiteral. We should remove the second argument
to substitute_at entirely, as it's no longer used
|
|
|
|
|
| |
`Computer` class needs to be require
See #17217 for more details
|
|
|
|
| |
Working with two different machines is hard :sweat:
|
|
|
|
|
|
| |
[Matthew Draper & Yves Senn]
Closes #16860. (pull request to discuss the implementation)
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
* Also duplicated find_by tests from relations_test.rb to finder_test.rb now
that we have a completely different implementation on the class (in core.rb
with AST caching stuff).
* Also removed a (failing) test that used mocks. Now that we have tests for the
behavior, there's no point having another test that tests the implementation
(that it delegates). Further, what the test was implying is nolonger true with
the current implementation, because Class.find_by is a real method now.
|
|
|
|
| |
All preload tests are in the eager_test file
|
|
|
|
|
|
|
|
| |
It appears that the only time that `quote` is called with a column,
but without first calling `type_cast` is when where is called with an
array. My previous pull request broke this behavior, without failing
tests. This adds a test for the only case I can think of that exercises
the `if column.type == :integer` branch of `quote` effectively.
|
|\
| |
| |
| | |
Fixed a problem where `sum` used with a `group` was not returning a Hash.
|
| |
| |
| |
| | |
with a grouping was not returning a Hash.
|
| | |
|
|/
|
|
|
|
|
|
|
| |
When relation scopes include one of `uniq`, `group`, `having` or
`offset`, the generated query ignores them and that causes unintended
records to be deleted. This solves the issue by restricting the deletion
when those scopes are present.
rails/rails#11985
|
|
|
|
|
|
|
|
| |
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
|
|\
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
* 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
|
| |
| |
| |
| |
| |
| |
| | |
properly return an empty hash instead of zero. Fixes issue #14721
Conflicts:
activerecord/CHANGELOG.md
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
968c581ea34b5236af14805e6a77913b1cb36238 have introduced this bug #14744
on Association Relation when the method `empty?` or `size` was called.
Example:
# Given an author that does have 3 posts, but none of them with the
# title 'Some Title'
Author.last.posts.where(title: 'Some Title').size
# => 3
It was occurring, because the Association Relation had implemented these
methods based on `@association`, this way giving wrong results.
To fix it, was necessary to remove the methods `empty?` and `size` from
Association Relation. It just have to use these methods from Relation.
Example:
# Given an author that does have 3 posts, but none of them with the
# title 'Some Title'
Author.last.posts.where(title: 'Some Title').size
# => 0
# Now it will return the correct value.
Fixes #14744.
|
|\|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
* 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
...
|
| | |
|
| | |
|
| | |
|
| | |
|
|\|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
* 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]
...
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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"
|
| |
| |
| |
| |
| |
| | |
CollectionProxy should be able to reuse the behavior (methods) of its parent class,
but with its own state. This change allows CollectionProxy to use the arel object
corresponding to its association's scope.
|
|\|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
* 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
|
| |
| |
| |
| | |
Closes #14406.
|
|\|
| |
| |
| |
| |
| | |
* master:
passing an instance of an AR object to `find` is deprecated
passing an ActiveRecord object to `exists?` is deprecated.
|
| |
| |
| |
| | |
please pass the id of the AR object by calling `.id` on the model first.
|
| |
| |
| |
| |
| | |
Pass the id of the object to the method by calling `.id` on the AR
object.
|
|\|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
* 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.
...
|
| |
| |
| |
| | |
This is a result of the discussion at https://github.com/rails/rails/pull/14263/files#r10291489
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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.
|
|\|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
* 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]
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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.
|
|\|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
* master: (311 commits)
Add a missing changelog entry for #13981 and #14035
Revert "Fixed plugin_generator test"
implements new option :month_format_string for date select helpers [Closes #13618]
add factory methods for empty alias trackers
guarantee a list in the alias tracker so we can remove a conditional
stop exposing table_joins
make most parameters to the AliasTracker required
make a singleton for AssociationScope
pass the association and connection to the scope method
pass the tracker down the stack and construct it in the scope method
clean up add_constraints signature
remove the reflection delegate
remove klass delegator
remove railties changes. fixes #14054
remove chain delegate
remove scope_chain delegate
Add verb to sanitization note
fix path shown in mailer's templates
updated Travis build status image url
fix guide active_support_core_extensions. add Note to String#indent [ci skip]
...
Conflicts:
activerecord/lib/active_record/associations/join_dependency.rb
activerecord/test/cases/associations/association_scope_test.rb
|
| |
| |
| |
| |
| |
| |
| | |
With this we can write `Model#select(:aliased)`, `Model#order(:aliased)`,
`Model#reoder(aliased: :desc)`, etc.
Supplementary work to 54122067acaad39b277a5363c6d11d6804c7bf6b.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
This fixes a bug where `select(:id)` combined with `joins()` raised:
```
ActiveRecord::StatementInvalid: SQLite3::SQLException: ambiguous column name: id:
SELECT id, authors.author_address_id
FROM "posts"
INNER JOIN "authors"
ON "authors"."id" = "posts"."author_id"
ORDER BY posts.id LIMIT 3
```
The `select_values` are still String and Symbols because other parts (mainly calculations.rb)
rely on that fact.
/cc @tenderlove
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
This commit bring the famous ordinal Array instance methods defined
in ActiveSupport into ActiveRecord as fully-fledged finders.
These finders ensure a default ascending order of the table's primary
key, and utilize the OFFSET SQL verb to locate the user's desired
record. If an offset is defined in the query, calling #second adds
to the offset to get the actual desired record.
Fixes #13743.
|
|\|
| |
| |
| |
| |
| |
| |
| | |
* master:
rm dup code
Conflicts:
activerecord/test/cases/relations_test.rb
|
| |
| |
| |
| | |
https://github.com/rails/rails/blob/e64a83cdbd3ce836f3339c600c1006b20c23d8fd/activerecord/test/cases/relation/merging_test.rb#L80-91
|
| | |
|
| | |
|