Commit Graph

13165 Commits

Author SHA1 Message Date
Sean Griffin 850159bd2c Merge pull request #18478 from yoshiokatsuneo/active_record_connection_pool_error_disconnect
ActiveRecord: On reconnection failure, release only failed connetion.
2015-01-13 12:31:52 -07:00
Yoshioka Tsuneo 33fdb7f292 ActiveRecord: On reconnection failure, release only failed connetion.
On reconnection failure, all the connection was released.
But, it is better to release only failed connection.
This patch changes not to release all the connection but release
only failed connection.
2015-01-13 13:49:40 +09:00
robertomiranda 5cca205114 Add Secure Token Generator 2015-01-11 14:42:54 -05:00
Sean Griffin 7bb6208697 Deprecate passing a column to `quote`
It's only used to grab the type for type casting purposes, and we would
like to remove the type from the columns entirely.
2015-01-10 15:45:47 -07:00
Sean Griffin ac6e6545de Stop passing a column to `quote` in tests
I'm planning on deprecating the column argument to mirror the
deprecation in [arel].

[arel]: 6160bfbda1
2015-01-10 15:45:47 -07:00
Sean Griffin 268ee64e63 Stop passing a column to `quote` when finding by AR models
I'm planning on deprecating the column argument to mirror the
deprecation in [arel].

[arel]: 6160bfbda1
2015-01-10 15:45:46 -07:00
Sean Griffin 0b4fd69b8b Stop passing a column to `quote` when executing from a statement cache
I'm planning on deprecating the column argument to mirror the
deprecation in [arel].

[arel]: 6160bfbda1
2015-01-10 15:45:46 -07:00
Sean Griffin a00854e515 Stop passing a column to `quote` in `Relation#to_sql`
I'm planning on deprecating the column argument to mirror the
deprecation in [arel].

[arel]: 6160bfbda1
2015-01-10 15:45:46 -07:00
Sean Griffin e6ac56a848 Stop passing a column to `quote` when prepared statements are turned off
I'm planning on deprecating the column argument to mirror the
deprecation in [arel].

[arel]: 6160bfbda1
2015-01-10 15:45:46 -07:00
Roberto Miranda 0f931f2ff0 Fix Typo SecureToken [ci skip] 2015-01-10 16:56:21 -05:00
Sean Griffin 134abedf19 Stop passing a column to `quote` in `insert_fixture`
I'm planning on deprecating the column argument to mirror the
deprecation in [arel].

[arel]: 6160bfbda1
2015-01-10 12:42:02 -07:00
Sean Griffin 7a09fc55c0 Stop special casing null binary data in logging
There's very little value in logging "<NULL binary data>" instead of
just "nil". I'd like to remove the column from the equation entirely,
and this case is preventing us from doing so.
2015-01-10 12:26:51 -07:00
Sean Griffin 4d5e660789 Don't attempt to save dirty attributes which are not persistable
This sets a precident for how we handle `attribute` calls, which aren't
backed by a database column. We should not take this as a conscious
decision on how to handle them, and this can change when we make
`attribute` public if we have better ideas in the future.

As the composed attributes API gets fleshed out, I expect the
`persistable_attributes` method to change to
`@attributes.select(&:persistable).keys`, or some more performant
variant there-of. This can probably go away completely once we fully
move dirty checking into the attribute objects once it gets moved up to
Active Model.

Fixes #18407
2015-01-10 12:07:46 -07:00
Nobuyoshi Nakada 69e365d2f4 Use IO::NULL always 2015-01-10 15:11:05 +01:00
Sebastian Staudt a4139a1674 Fix typo in PostresSQLAdapter's documentation 2015-01-10 13:15:03 +01:00
Yves Senn a7621d7d53 formatting pass over CHANGELOGs. [ci skip] 2015-01-10 12:17:57 +01:00
Carlos Antonio da Silva f4fbc03010 Remove support for the protected attributes gem
Related to #10690.
2015-01-09 22:42:29 -02:00
robertomiranda 47316feee0 Switch Secure Token generation to Base58
Update Secure Token Doc [ci skip]

remove require securerandom, core_ext/securerandom already do that ref 7e006057
2015-01-09 18:47:44 -05:00
Arthur Neves 86a853e4ec Copy records to parent transaction should happen on TransactionManager
It is up to the TransactionManager keep the state of current transaction, so after it commits it needs to copy any remaning record to the next current transaction
2015-01-09 15:54:20 -05:00
Arthur Neves c7f56d99e5 Use keyword args on committed! and rolledback!
As discussed before, those methods should receive a keyword args instead of just parameters
2015-01-09 15:35:51 -05:00
Sean Griffin ec475547a9 Properly copy nested bind values from subqueried relations
This is cropping up all over the place. After a brief dive, I'm really
not sure why we have `arel.bind_values` at all. A cursory grep didn't
reveal where they're actually being assigned (it's definitely in AR, not
in Arel). I'd like to dig further into it, as I'm fairly certain we
don't actually need it, we just need a way for the predicate builder to
communicate merged binds upstream.

Fixes #18414
2015-01-09 10:31:23 -07:00
Sean Griffin 13772bfa49 Properly persist `lock_version` as 0 if the DB has no default
The reason this bug occured is that we never actually check to see if
this column has changed from it's default, since it was never assigned
and is not mutable.

It appears I was wrong in b301c40224, with
my statement of "there is no longer a case where a given value would
differ from the default, but would not already be marked as changed."

However, I chose not to revert the deletion of
`initialize_internals_callback` from that commit, as I think a solution
closer to where the problem lies is less likely to get erroneously
removed. I'm not super happy with this solution, but it mirrors what is
being done in `_update_record`, and a fix for one should work for the
other.

I toyed with the idea of changing the definition of `changed?` on the
type to `changed_in_place?`. If we type cast the raw value, it'll break
a test about updating not modifying the lock column if nothing else was
changed. We could have the definition check if `raw_old_value` is `nil`,
but this feels fragile and less intention revealing. It would, however,
have the benefit of cleaning up old data that incorrectly persisted as
`nil`.

Fixes #18422
2015-01-09 09:56:15 -07:00
Yoshioka Tsuneo 205a561e50 ActiveRecord: release connection on reconnect failure.
When trying to checkout connection from connection pool,
checkout()(and checkout_and_verify) verify whether the connection
is active or not.
And, if the connection is not active, connection adapters try to
reconnect to server.  And, if database is down at this moment,
reconnect fails and exception is raised.
(Ex: Mysql2::Error: Can't connect to local MySQL server through socket xxx)

But, ConnectionPool does not catch the exception, but leaks current
disconnected connection to @connection.
So, if database's temporary down happens several times and exceeds
the number of connection pool(5 by default), activerecord will be
no more available, even if database server is already recovered.

This patch fix it by catching exception and releasing connection.
2015-01-09 14:33:17 +09:00
Caleb Thompson 17136c2013 Document has_many :extend option
5937bd02de (commitcomment-9205786)
2015-01-08 12:20:37 -06:00
Godfrey Chan f6b21d48ef Merge pull request #16640 from mfazekas/fix_loop_in_changed_for_autosave
Fix potenital infinite recursion in changed_for_autosave?
2015-01-07 15:56:50 -08:00
brainopia 824862807b Fix count on a separate connection (fixes #18359)
Previosly count and other AR calculations would convert
column_name_for_operation to sql on a default Arel::Table.engine
(AR::Base) connection. That could lead to trouble if current
model has a connection to a different adapter or Base connection
is inaccessible.
2015-01-08 01:42:33 +03:00
Kuldeep Aggarwal d4c5406279 fix `attribute` method scoping(i.e. private)
ref #52f641264b1325a4c2bdce7971b14524bd4905f1
2015-01-06 21:46:35 +05:30
Rafael Mendonça França 52f641264b Merge pull request #18362 from georgemillo/attribute
replacing 'attribute' method with an alias
2015-01-06 11:16:49 -03:00
Prathamesh Sonpatki 0e3eca8a93 Fixed typos and wording in ActiveRecord CHANGELOG [ci skip] 2015-01-06 18:39:58 +05:30
Yves Senn dd54b518ce Merge pull request #18358 from prathamesh-sonpatki/add-test-for-non-string-labeled-fixtures
Fix lookup of fixtures with non-string(like Fixnum) label
2015-01-06 13:31:50 +01:00
George Millo ff286eb3e3 replacing 'attribute' method with an alias 2015-01-06 12:20:58 +00:00
Prathamesh Sonpatki 8da936a5d3 Fix lookup of fixtures with non-string label
- Fixtures with non-string labels such as integers should be accessed
   using integer label as key. For eg. pirates(1) or pirates(42).
 - But this results in NotFound error because the label is converted into string before
   looking up into the fixtures hash.
 - After this commit, the label is converted into string only if its a
   symbol.
 - This issue was fount out while adding a test case for
   https://github.com/rails/rails/commit/7b910917.
2015-01-06 17:15:39 +05:30
Sean Griffin 1ab7eba89b Merge pull request #18350 from brainopia/fix_build_from_bind_values
Propagate bind_values from join in subquery
2015-01-05 17:09:23 -07:00
brainopia 42e386173f Correctly fetch bind_values from join in subquery 2015-01-06 02:29:03 +03:00
Sean Griffin 00dad0343b Define attribute methods before attempting to populate records
`initialize_internals_callback` will attempt to assign attributes from
the current scope, which will fail if something defined the method
and calls super (meaning it won't hit `method_missing`).

Fixes #18339
2015-01-05 14:46:27 -07:00
Sean Griffin 3d0c718644 Whitespace fixes from #18349 2015-01-05 14:20:23 -07:00
Sean Griffin 08d6eb2370 Merge pull request #18349 from jdelStrother/primarykeyless
Fix rollback of primarykey-less tables
2015-01-05 14:19:01 -07:00
Jonathan del Strother f634c1fcf4 Fix rollback of primarykey-less tables
If you have a table without a primary key, and an `after_commit` callback on that table (ie `has_transactional_callbacks?` returns true), then trying to rollback a transaction involving that record would result in “ActiveModel::MissingAttributeError: can't write unknown attribute ``”
2015-01-05 20:47:41 +00:00
Ray Zane ac41f6a5d7 Add firebird support to test suite 2015-01-05 13:34:59 -03:00
Rafael Mendonça França d972537faa Merge pull request #18344 from jonatack/patch-1
Clean up secure_token_test
2015-01-05 12:31:37 -03:00
Matt Hogan 7b910917d3 Fix TypeError in Fixture creation
Ruby 4.2 started doing `value.gsub('$LABEL', label)` for fixture label interpolation, but you can have have valid YAML where `label` isn't a String. 

For example:

```YAML
0:
  name: John
  email: johndoe@gmail.com
1:
  name: Jane
  email: janedoe@gmail.com
```

This YAML will create a label that is a Fixnum, causing `TypeError: no implicit conversion of Fixnum into String.`
2015-01-05 09:02:44 -06:00
Jon Atack 2f05036cdd Clean up secure_token_test 2015-01-05 15:41:53 +01:00
Carlos Antonio da Silva e50064c130 Fix typo in changelog [ci skip] 2015-01-05 08:49:02 -02:00
Yves Senn 4ed97979d1 remove deprecated support to preload instance-dependent associaitons.
Addresses ed56e596a0 (commitcomment-9145960)
2015-01-05 11:44:14 +01:00
Yves Senn a076256d63 remove deprecated support for PG ranges with exclusive lower bounds.
addresses 91949e48cf (commitcomment-9144563)
2015-01-05 11:09:29 +01:00
Yves Senn 5cc08e1977 can't kill thread with in-memory db. fixes `rake test:sqlite3_mem`. 2015-01-05 10:33:05 +01:00
Yves Senn 3ae9818143 remove deprecation warning when modifying a Relation with cached arel.
This adresses 1b7aa62b18 (commitcomment-9147803)
2015-01-05 10:08:56 +01:00
Yves Senn 65520c29f7 add punctuation. [ci skip] 2015-01-05 09:16:40 +01:00
Miklos Fazkeas fb71fa695d Fix potenital stack level too deep with autosave or validation
When associations checked for autosave have a cycle, and
none of them is dirty, then changed_for_autosave? will be an
infinite loop. We now remember if we're in the check and
will short circuit the recursion.
2015-01-04 23:44:51 +01:00
Rafael Mendonça França cf01d01bd9 Remove version conditional for calling GC.disable 2015-01-04 15:54:21 -03:00