Commit Graph

775 Commits

Author SHA1 Message Date
Matthew Draper
9e457a8654 Reap connections based on owning-thread death
.. not a general timeout.

Now, if a thread checks out a connection then dies, we can immediately
recover that connection and re-use it.

This should alleviate the pool exhaustion discussed in #12867. More
importantly, it entirely avoids the potential issues of the reaper
attempting to check whether connections are still active: as long as the
owning thread is alive, the connection is its business alone.

As a no-op reap is now trivial (only entails checking a thread status
per connection), we can also perform one in-line any time we decide to
sleep for a connection.
2014-03-18 10:33:00 +10:30
Yves Senn
8ba60912ca where.not adds references for includes.
Closes #14406.
2014-03-17 14:20:23 +01:00
Yves Senn
a0c1c18e4d format ActiveRecord CHANGELOG. [ci skip] 2014-03-17 08:44:56 +01:00
Eric Steele
f47421f2a0 Extend fixture label replacement to allow string interpolation
Allows fixtures to use their $LABEL as part of a string instead
of limiting use to the entire value.

    mark:
      first_name: $LABEL
      username: $LABEL1973
      email: $LABEL@$LABELmail.com

    users(:mark).first_name # => mark
    users(:mark).username   # => mark1973
    users(:mark).email      # => mark@markmail.com
2014-03-15 22:11:36 -04:00
Arthur Neves
433b19d7e8 Make select_all on query cache accept a Relation without binds.
[fixes #14361]
[related #13886]
2014-03-13 15:01:37 -04:00
Aaron Patterson
d35f0033c7 passing an instance of an AR object to find is deprecated
please pass the id of the AR object by calling `.id` on the model first.
2014-03-13 11:47:12 -07:00
Aaron Patterson
d92ae6ccca passing an ActiveRecord object to exists? is deprecated.
Pass the id of the object to the method by calling `.id` on the AR
object.
2014-03-13 11:40:35 -07:00
Rafael Mendonça França
591b8f395d Merge pull request #13040 from kamipo/case_sensitive_comparison
Only use BINARY for mysql case sensitive uniqueness check when column has a case insensitive collation.

Conflicts:
	activerecord/CHANGELOG.md
2014-03-12 10:51:10 -03:00
Arthur Neves
2ed1cbba52
Changelog entry for mysql56 microseconds 2014-03-12 09:20:22 -04:00
lsylvester
b3e0da3062 register OID for PostgreSQL citex datatype [Troy Kruthoff & Lachlan Sylvester]
citext makes it possible to use AR Hash finders for case-insensitive matching as sql UPPER/LOWER functions are not needed.
2014-03-11 08:14:03 +11:00
Rafael Mendonça França
6e3ab3e15f Merge pull request #8313 from alan/only_save_changed_has_one_objects
Save has_one associations only if record has changes

Conflicts:
	activerecord/CHANGELOG.md
2014-03-10 11:41:55 -03:00
Robin Dupret
058d3c6183 Remove a reference to an issue [ci skip]
This actually not an issue fixing ; the changelog is referring to the
introducing pull request itself.
2014-03-05 14:00:23 +01:00
Yves Senn
54a120ed55 quick pass over Active Record CHANGELOG. [ci skip]. 2014-03-05 09:07:12 +01:00
Marcelo Casiraghi
acbd7ab22e Allow string hash values on AR order method
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.
2014-03-04 18:20:00 +01:00
Dieter Komendera
5c55aafd38 Add Enum type to postgresql adapter's oids to prevent unknown OID warnings. 2014-03-04 10:32:20 +01:00
Yves Senn
d1e7cd14c2 includes uses SQL parsing when String joins are involved.
This is a partial revert of 22b3481ba2aa55fad1f9a5db94072312b345fb55.
The current implementation of `references_eager_loaded_tables?` needs to know
every table involved in the query. With the current API this is not possible
without SQL parsing.

While a2dab46cae35a06fd5c5500037177492a047c252 deprecated SQL parsing for `includes`.
It did not issue deprecation warnings when String joins are involved. This resulted
in a breaking change after the deprecated behavior was removed (22b3481ba2aa55fad1f9a5db94072312b345fb55).

We will need to rethink the usage of `includes`, `preload` and `eager_load` but for now,
this brings back the old *working* behavior.
2014-02-28 09:56:07 +01:00
TheMonster
6e53d92498 Fix a bug affecting validations of enum attributes
This fixes a bug where any enum attribute of a model
would be evaluated always as 0 when calling the
database on validations.

This fix converts the value of the enum attribute
to its integer value rather than the string before
building the relation as the bug occured when the
string finally gets converted to integer using
string.to_i which converts it to 0.

[Vilius Luneckas, Ahmed AbouElhamayed]
2014-02-27 23:54:49 +02:00
Aaron Patterson
b1656fa630 let insert_record actuall save the object.
`before_add` callbacks are fired before the record is saved on
`has_and_belongs_to_many` assocations *and* on `has_many :through`
associations.  Before this change, `before_add` callbacks would be fired
before the record was saved on `has_and_belongs_to_many` associations, but
*not* on `has_many :through` associations.

Fixes #14144
2014-02-25 14:57:49 -08:00
Jon Leighton
90ba6a762c Merge remote-tracking branch 'chancancode/fix_instance_method_already_implemented'
Conflicts:
	activerecord/CHANGELOG.md
2014-02-25 22:21:56 +00:00
Carlos Antonio da Silva
71b3910a7d Point master changelogs to 4-1-stable branch
Remove 4-1 related entries from master [ci skip]
2014-02-25 09:14:36 -03:00
Godfrey Chan
41554319f8 Fixed STI classes not defining an attribute method if there is a
conflicting private method defined on its ancestors.

The problem is that `method_defined_within?(name, klass, superklass)`
only works correclty when `klass` and `superklass` are both `Class`es.

If both `klass` and `superklass` are both `Class`es, they share the
same inheritance chain, so if a method is defined on `klass` but not
`superklass`, this method must be introduced at some point between
`klass` and `superklass`.

This does not work when `superklass` is a `Module`. A `Module`'s
inheritance chain contains just itself. So if a method is defined on
`klass` but not on `superklass`, the method could still be defined
somewhere upstream, e.g. in `Object`.

This fix works by avoiding calling `method_defined_within?` with a
module while still fufilling the requirement (checking that the
method is defined withing `superclass` but not is not a generated
attribute method).

4d8ee288 is likely an attempted partial fix for this problem. This
unrolls that fix and properly check the `superclass` as intended.

Fixes #11569.
2014-02-23 11:00:55 -08:00
Yves Senn
d9314b4c0a Coerce strings when reading attributes. 2014-02-23 13:42:16 +01:00
Yves Senn
91949e48cf deprecate support for pg ranges with excluding beginnings.
The Ruby Range object does not support excluding beginnings.
We currently support excluding beginnings for some subtypes using
manually by incrementing them (now using the `#succ` method).
This is approach is flawed as it's not equal to an excluding beginning.

This commit deprecates the current support for excluding beginnings.
It also raises an `ArgumentError` for subtypes that do not implement the `succ`
method.

This is a temporary solution to get rid of the broken state. We might still
add complete support for excluding beginnings afterwards. (Probably with a
new `PGRange` object, which acts like a `Range` but has excluding beginnings.
2014-02-23 12:47:30 +01:00
Yves Senn
4cb47167e7 dynamically define PostgreSQL OID range types.
This gets AR working with custom defined range types. It also
removes the need for subtype specific branches in `OID::Range`.

This expands the interface of all `OID` types with the `infinity` method.
It's responsible to provide a value for positive and negative infinity.
2014-02-23 12:47:30 +01:00
Amit Thawait
b74490e4f2 Typo fix for unscope 2014-02-18 11:26:54 -08:00
Rafael Mendonça França
1879c259b8 Merge branch '4-1-0-beta2'
Conflicts:
	actionview/CHANGELOG.md
	activerecord/CHANGELOG.md
2014-02-18 16:00:47 -03:00
Rafael Mendonça França
8b20c72dd8 Preparing for 4.1.0.beta2 release 2014-02-18 15:45:20 -03:00
Rafael Mendonça França
fc641a1a5b Don't use # => when it is not the expression values
[ci skip]
2014-02-18 13:49:31 -03:00
Rafael Mendonça França
967a6dc898 Fix the column name [ci skip] 2014-02-18 13:49:31 -03:00
Rafael Mendonça França
6370e69143 Document the default scopes change on the release notes, CHANGELOG
and upgrating guides

[ci skip]
2014-02-18 13:49:30 -03:00
Rafael Mendonça França
a2075f4142 Revert "Merge pull request #13344 from ccutrer/fix-from-default-select"
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.
2014-02-17 10:49:38 -03:00
Rafael Mendonça França
99cdad6d9c Fix typo [ci skip] 2014-02-16 21:49:50 -03:00
Josh Goodall
da3fec2ea3 Resolve encoding issues with arrays of hstore (bug 11135).
We didn't have enough encoding for the wire protocol to store an array
of hstore types. So, further encode any hstore that is an array member.
Whilst we're here, ensure it's an HashWithIndifferentAccess being
returned, to be consistent with other serialized forms, and add testing
for arrays of hstore.

So now the following migration:

  enable_extension "hstore"
  create_table :servers do |t|
    t.string  :name
    t.hstore  :interfaces, array: true
  end

produces a model that can used like this, to store an array of hashes:

  server = Server.create(name: "server01", interfaces: [
    { name: "bge0", ipv4: "192.0.2.2", state: "up" },
    { name: "de0", state: "disabled", by: "misha" },
    { name: "fe0", state: "up" },
  ])

More at http://inopinatus.org/2013/07/12/using-arrays-of-hstore-with-rails-4/
2014-02-17 00:40:16 +02:00
Robin Dupret
0c63fbcdf1 Add a missing changelog entry for #13981 and #14035
[ci skip]
2014-02-15 21:07:13 +01:00
Hubert Dąbrowski
e1d4673102 Drop the correct index after reverting a migration
Previously when reverting a migration which added a named index it
would instead drop a corresponding index with matching columns but
without a name.
2014-02-13 17:18:16 +01:00
Xavier Noria
c0fb8d0b9c Merge branch 'dump-schema-after-migration-flag' of git://github.com/emilsoman/rails into emilsoman-dump-schema-after-migration-flag
Conflicts:
	activerecord/CHANGELOG.md
2014-02-06 15:03:20 +01:00
Emil Soman
8806768e9f Add config to disable schema dump after migration
* Add a config on Active Record named `dump_schema_after_migration`
* Schema dump doesn't happen if the config is set to false
* Set default value of the config to true
* Set config in generated production environment file to false
* Update configuration guide
* Update CHANGELOG
2014-02-06 17:38:31 +05:30
Yves Senn
580f0b61dc synchronize 4.1 release notes with CHANGELOGS. [ci skip]
/cc @chancancode
2014-02-06 11:43:16 +01:00
Marc-Andre Lafortune
a476020567 Return sized enumerator from Enumerable#index_by 2014-02-05 16:53:58 -05:00
Marc-Andre Lafortune
13d2696c10 Return sized enumerator from Batches#find_each 2014-02-05 16:53:02 -05:00
Marc-Andre Lafortune
d37f395be8 Return sized enumerator from Batches#find_in_batches 2014-02-05 16:49:29 -05:00
Rafael Mendonça França
404cb36ee3 Add CHANGELOG entry for #13935 [ci skip] 2014-02-04 12:13:14 -02:00
Yves Senn
06dde5fbf5 some wording format changes. [ci skip] 2014-02-03 14:52:01 +01:00
Yves Senn
584a46479b pass habtm :autosave to underlying hm:t association. Closes #13923. 2014-02-03 14:48:59 +01:00
Rafael Mendonça França
83ea905fd1 Merge pull request #13688 from jbaudanza/psql-index-exists
PostgreSQL implementation of SchemaStatements#index_name_exists?

Conflicts:
	activerecord/CHANGELOG.md
2014-02-01 16:01:38 -02:00
Mauricio Linhares
a34c10f73e Fixes issue with parsing whitespace content back from database - fixes #13907 2014-02-01 09:38:43 -03:00
Carlos Antonio da Silva
8c7e8b4f18 Minor changelog improvements [ci skip] 2014-01-31 08:02:56 -02:00
Lauro Caetano
4506dd2f07 Associations now raise ArgumentError on name conflicts.
Dangerous association names conflicts include instance or class
methods already defined by `ActiveRecord::Base`.
2014-01-31 00:29:48 -02:00
Arthur Neves
b7fcad8ff0 Fix regression on .select_* methods.
This was a common pattern:
```
query = author.posts.select(:title)
connection.select_one(query)
```

However `.select` returns a ActiveRecord::AssociationRelation, which has
the bind information, so we can use that to get the right sql query.

Also fix select_rows on postgress and sqlite3 that were not using the binds

[fixes #7538]
[fixes #12017]
[related #13731]
[related #12056]
2014-01-30 14:06:40 -05:00
Rafael Mendonça França
5977e7e4d5 Aesthetic 2014-01-29 20:48:43 -02:00