Commit Graph

53819 Commits

Author SHA1 Message Date
Sean Griffin
0a6c4019df Merge pull request #20957 from akihiro17/find-by-issue
Fix find_by with association subquery issue
2015-10-20 15:25:29 -06:00
Sean Griffin
7b92798d2f Merge pull request #21302 from theunraveler/delegate_reserved_argument_names
ActiveSupport: Fixing issue when delegating to methods named "block", "args", or "arg"
2015-10-20 15:04:05 -06:00
Sean Griffin
3e29d96ecd Fix test failures caused by d99db6b8b3e4
I messed up the merge conflict, and accidentally removed a schema query
that needed to be ignored.
2015-10-20 14:54:22 -06:00
Sean Griffin
03aacc55a2 Merge pull request #21756 from soutaro/qualify-column-in-calculation
Qualify column names in calculation
2015-10-20 14:48:26 -06:00
Soutaro Matsumoto
a7628099de Qualify column names in calculation
Column names inserted via `group` have to be qualified with table name.
2015-10-20 14:47:55 -06:00
Sean Griffin
d99db6b8b3 Merge pull request #18856 from al2o3cr/issue_17897
Match table names exactly on MySQL
2015-10-20 14:39:53 -06:00
Sean Griffin
4c42c89b04 Fix merge conflicts for #18856 2015-10-20 14:39:24 -06:00
Sean Griffin
0ceaa733aa Don't add classes to the top level namespace
I've been writing too much Rust. My mind is still in the mode of things
being auto-namespaced based on the file...
2015-10-20 14:22:52 -06:00
Sean Griffin
8b64aba17b Merge pull request #21883 from tarzan/cache-key-too-precise
Fix precision on cache_key
2015-10-20 14:20:32 -06:00
Sean Griffin
cbcdecd2c5 Do not cache prepared statements that are unlikely to have cache hits
Prior to this commit, Rails makes no differentiation between whether a
query uses bind parameters, and whether or not we cache that query as a
prepared statement. This leads to the cache populating extremely fast in
some cases, with the statements never being reused.

In particular, the two problematic cases are `where(foo: [1, 2, 3])` and
`where("foo = ?", 1)`. In both cases we'll end up quoting the values
rather than using a bind param, causing a cache entry for every value
ever used in that query.

It was noted that we can probably eventually change `where("foo = ?",
1)` to use a bind param, which would resolve that case. Additionally, on
PG we can change our generated query to be `WHERE foo = ANY($1)`, and
pass an array for the bind param. I hope to accomplish both in the
future.

For SQLite and MySQL, we still end up preparing the statements anyway,
we just don't cache it. The statement will be cleaned up after it is
executed. On postgres, we skip the prepare step entirely, as an API is
provided to execute with bind params without preparing the statement.

I'm not 100% happy on the way this ended up being structured. I was
hoping to use a decorator on the visitor, rather than mixing a module
into the object, but the way Arel has it's visitor pattern set up makes
it very difficult to extend without inheritance. I'd like to remove the
duplication from the various places that are extending it, but that'll
require a larger restructuring of that initialization logic. I'm going
to take another look at the structure of it soon.

This changes the signature of one of the adapter's internals, and will
require downstream changes from third party adapters. I'm not too
worried about this, as worst case they can simply add the parameter and
always ignore it, and just keep their previous behavior.

Fixes #21992.
2015-10-20 14:16:22 -06:00
Sean Griffin
72fba7db41 Merge pull request #21932 from kamipo/add_stored_procedure_test_in_mysql2
Add stored procedure test in mysql2
2015-10-20 14:02:23 -06:00
Sean Griffin
ee865eb244 Merge pull request #21962 from kamipo/fix_tinyblob
Fix to correctly schema dump the `tinyblob`
2015-10-20 14:01:54 -06:00
Rafael Mendonça França
cbfe5bb3c4 Upgrade all the gems 2015-10-20 15:58:57 -02:00
Rafael Mendonça França
2ba92bb809 Merge branch 'fix-21955' 2015-10-20 15:30:38 -02:00
Rafael Mendonça França
209f3b30af Add CHANGELOG entry for fix of #21955 [ci skip] 2015-10-20 15:30:09 -02:00
Rafael Mendonça França
f684b7ac8c Merge pull request #21974 from jbranchaud/reorder-has-many-assocation-constraints
Reorder application of has_many association constraints.
2015-10-20 15:26:22 -02:00
kal
dda4f60890 Changed the order of Association constraints from where->order->unscope to unscope->where->order 2015-10-20 15:25:05 -02:00
Rafael Mendonça França
d68e81afa0 Merge pull request #21858 from Gaurav2728/protected_method_nodoc
nodoc for active support protected method [CI skip]
2015-10-20 15:04:00 -02:00
Yves Senn
8572634450 Merge pull request #22003 from yui-knk/remove_needless_require_as
Delete needless `require 'active_support/deprecation'`
2015-10-20 13:46:50 +02:00
Yves Senn
b6127d8871 Merge pull request #22004 from yui-knk/fix_method_to_action
[ci skip] Replace "destroy` method" with `destroy` action`
2015-10-20 13:43:16 +02:00
yui-knk
666e2cc654 [ci skip] Replace "destroy method" with destroy action
Sure this is `destroy` method of PhotosController, but in this chapter
these methods which mapped by the router are called "action".
For example:

```ruby
get '/patients/:id', to: 'patients#show'
```

is described to dispatch "controller's `show` action".
2015-10-20 20:24:07 +09:00
yui-knk
1099329be0 Delete needless require 'active_support/deprecation'
When `require 'active_support/rails'`, 'active_support/deprecation'
is automatically loaded.
2015-10-20 20:02:59 +09:00
Sean Griffin
9be4ea8184 Merge pull request #21978 from ctreatma/console_helper_reload
Fix #21977: Removes memoization of helpers in Rails console
2015-10-19 19:41:15 -06:00
Sean Griffin
09f057d193 Merge pull request #21987 from yui-knk/refactor_where
Green version of moving the handling of supported arguments to `where`
2015-10-19 19:39:55 -06:00
Sean Griffin
d57d5595c0 Merge pull request #22001 from cleverlemming/doc_patch_engines
Added context for running engine:migrations:install task. [ci skip]
2015-10-19 19:36:43 -06:00
Simon H
407c87011d added Rails 4 context for migrations:install task 2015-10-19 17:33:02 -06:00
Claudio B.
b859d97081 Merge pull request #21991 from philr/doc_tzinfo_no_longer_bundled
Remove outdated documentation regarding a bundled version of TZInfo
2015-10-19 13:48:12 -07:00
Santiago Pastorino
b456e76f58 Merge pull request #21999 from agis-/param-encoding-errors
Show helpful messages on invalid param. encodings
2015-10-19 13:11:19 -02:00
Agis Anastasopoulos
3f81b3753f Show helpful messages on invalid param. encodings
Prior to this change, given a route:

    # config/routes.rb
    get ':a' => "foo#bar"

If one pointed to http://example.com/%BE (param `a` has invalid encoding),
a `BadRequest` would be raised with the following non-informative message:

    ActionController::BadRequest

From now on the message displayed is:

    Invalid parameter encoding: hi => "\xBE"

Fixes #21923.
2015-10-19 17:36:22 +03:00
jbranchaud
d9bb13ba04 Reorder application of has_many association constraints.
With `unscope!` called last, it undoes `where` constraints of the same
value when the `where` is chained after the `unscope`. This is what a
`rewhere` does. This is undesirable behavior.

The included tests demonstrate both the `unscope(...).where(...)`
behavior as well as the direct use of `rewhere(...)`.

This is in reference to #21955.
2015-10-19 09:30:33 -05:00
Phil Ross
2cecd21370 Remove outdated statement about bundled TZInfo.
The bundled version of TZInfo referred to was removed from Active
Support in version 3.0.
2015-10-18 22:06:54 +01:00
Arthur Nogueira Neves
dd2c94aea6 Merge pull request #21988 from y-yagi/remove_useless_method
remove useless method
2015-10-18 11:46:04 -04:00
Eileen M. Uchitelle
c2ed6bfab2 Merge pull request #21989 from imtayadeway/guides/active-model-basics
[ci skip] Improve readability in active model basics guide
2015-10-18 10:46:13 -04:00
Tim Wade
3c0ae9da87
[ci skip] Improve readability in active model basics guide
* adds/removes a few words
* removes an unnecessary comma
2015-10-18 07:35:54 -07:00
yuuji.yaginuma
93d99c55bd remove useless method
`images` method has been deleted in 2bc4856, `create_images_directory` does nothing.
2015-10-18 15:41:07 +09:00
yui-knk
b27fb2d8e7 Green version of moving the handling of supported arguments to where
This commit follow up of 4d8f62d.
The difference from 4d8f62d are below:

* Change `WhereClauseFactory` to accept `Arel::Nodes::Node`
* Change test cases of `relation_test.rb`
2015-10-18 10:51:03 +09:00
Rafael Mendonça França
6c36c369be Revert "Move the handling of supported arguments to where"
This reverts commit 4d8f62dcfa0a5157b3facbd71f75fc6639636347.

Reason: This broke the build. Please recommit again when it is green.
2015-10-17 19:40:10 -03:00
Yves Senn
bae2292d8f Merge pull request #21982 from yui-knk/test_suppress_warning
Suppress warnings of `assigned but unused variable`
2015-10-17 16:44:16 +02:00
Richard Schneeman
a5e1bc813b Merge pull request #21980 from maratgaliev/timezones_fix
Use "rake time:zones:all" instead of "rake -D time" [ci skip]
2015-10-17 08:38:10 -05:00
yui-knk
3973a48307 Suppress warnings of assigned but unused variable 2015-10-17 17:16:16 +09:00
Marat Galiev
706850a443 Use "rake time:zones:all" instead of "rake -D time" [ci skip] 2015-10-17 09:17:42 +03:00
Charles Treatman
fa65b44b28 Fix #21977: Removes memoization of helpers in Rails console
In the Rails console, the `helper` function provides a shorthand for
working with application helpers.  However, `helper` memoizes the
value of `ApplicationController#helpers`. This means that if a user
subsequently changes helper code and calls `reload!` in the console,
their code changes will not be reflected by the `helper` function,
even though the helper was, in fact, reloaded.
2015-10-16 19:28:38 -04:00
schneems
101821410b [ci skip] Add backend queue starting documentation
If you can't start your queue, you won't process much. This change adds external links to the Queue backends that have Active Job specific docs.
2015-10-16 18:24:58 -05:00
Sean Griffin
4d8f62dcfa Move the handling of supported arguments to where
`WhereClauseFactory` handles all other branches based on argument types,
so the code fits more naturally here, and it's just where the
responsibility belongs.
2015-10-16 09:51:47 -07:00
Matthew Draper
833aef438d Merge pull request #21953 from bdunne/fix_dep_warn
Fix deprecation warning messages on deprecate_methods
2015-10-17 03:17:21 +10:30
Sean Griffin
cd4575f98c Merge pull request #21944 from jwworth/issue-20473
where raises ArgumentError on unsupported argument types
2015-10-16 09:25:39 -07:00
Jake Worth
7663376f07 where raises ArgumentError on unsupported types.
[#20473]
2015-10-16 09:23:15 -05:00
Maarten Jacobs
86d2924a11 fixes #21815
The default timestamp used for AR is `updated_at` in nanoseconds! (:nsec) This causes issues on any machine that runs an OS that supports nanoseconds timestamps, i.e. not-OS X, where the cache_key of the record persisted in the database (milliseconds precision) is out-of-sync with the cache_key in the ruby VM.

This commit adds:

A test that shows the issue, it can be found in the separate file `cache_key_test.rb`, because
- model couldn't be defined inline
- transactional testing needed to be turned off to get it to pass the MySQL tests
This seemed cleaner than putting it in an existing testcase file.

It adds :usec as a dateformat that calculates datetime in microseconds

It sets precision of cache_key to :usec instead of :nsec, as no db supports nsec precision on timestamps
2015-10-16 15:09:45 +02:00
Yves Senn
b3656076d6 Merge pull request #21969 from ignatiusreza/remove_readonly_option_doc
Remove mentioned of 'readonly' options in doc for HABTM [ci skip]
2015-10-16 10:32:09 +02:00
Ignatius Reza
15f7519361 [ci skip] readonly options has been removed 2015-10-16 16:52:19 +09:00