Commit Graph

13804 Commits

Author SHA1 Message Date
George Claghorn
ac002395d8 Apply Active Record suppression to all saves
It was not being applied to creates and updates attempted through the
non-bang save methods. This means that, for example, creation of
records for singular associations through the `create_*` methods was
not appropriately ignored in .suppress blocks.
2015-06-04 00:11:38 -04:00
Roque Pinel
efa1648f28 [ci skip] fix the collection.clear guide
Improve the guide about `has_many` `collection.clear` to indicate
the behavior for each dependent strategy according to
`collection.delete_all`.

Based on #17179, I changed the `collection.delete` docs to also
clarify the default strategy for each `hm` and `hm:t` associations.

Fixes #20170.
2015-06-02 22:16:10 -05:00
Sean Griffin
b6b13905e5 Skip test that fails from outdated sqlite3 on travis 2015-06-02 07:29:44 -06:00
Kevin Deisz
2dd95a775c Fix postgresql DISTINCT requirement in pluck test 2015-06-02 05:36:24 -04:00
Rafael Mendonça França
a4cf371e11 Merge pull request #20405 from manish-shrivastava/master
Fixed typos in rails guide
2015-06-01 12:58:51 -03:00
manish-shrivastava
8145880541 Fixed typos in guide 2015-06-01 21:16:30 +05:30
Rafael Mendonça França
4e63bde623 Merge pull request #20362 from kddeisz/enumerable_pluck
Allow Enumerable#pluck to take a splat.
2015-06-01 12:40:19 -03:00
Rafael Mendonça França
b8e8b67290 Merge pull request #20386 from yoongkang/circular_import
Fix circular import warning on build
2015-06-01 12:23:09 -03:00
Yasuo Honda
a9e6e6e07a Map :bigint as NUMBER(19) sql_type by using :limit => 19 for Oracle
since NUMBER(8) is not enough to store the maximum number of bigint.
Oracle NUMBER(p,0) as handled as integer
because there is no dedicated integer sql data type exist in Oracle database.

Also NUMBER(p,s) precision can take up to 38. p means the number of digits, not the byte length.
bigint type needs 19 digits as follows.

	$ irb
	2.2.2 :001 > limit = 8
	 => 8
	2.2.2 :002 > maxvalue_of_bigint = 1 << ( limit * 8 - 1)
	 => 9223372036854775808
	2.2.2 :003 > puts maxvalue_of_bigint.to_s.length
	19
	 => nil
	2.2.2 :004 >
2015-06-01 12:23:20 +00:00
Yves Senn
b25436abc4 minor formatting changes in changelogs. [ci skip] 2015-05-31 11:24:36 +02:00
Yoong Kang Lim
179b9f6a25 Fix circular import warning on build 2015-05-31 13:15:08 +10:00
Sean Griffin
0ef7e73f0a Ensure symbols passed to select are always quoted
Our general contract in Active Record is that strings are assumed to be
SQL literals, and symbols are assumed to reference a column. If a from
clause is given, we shouldn't include the table name, but we should
still quote the value as if it were a column.

Upon fixing this, the tests were still failing on SQLite. This was
because the column name being returned by the query was `"\"join\""`
instead of `"join"`. This is actually a bug in SQLite that was fixed a
long time ago, but I was using the version of SQLite included by OS X
which has this bug. Since I'm guessing this will be a common case for
contributors, I also added an explicit check with a more helpful error
message.

Fixes #20360
2015-05-30 12:35:51 -06:00
Sean Griffin
6bd2573869 Add docs and changelog entry for 73aab03 [ci skip] 2015-05-30 11:13:28 -06:00
Ryuta Kamizono
e5e3ec2085 Add CHANGELOG entry for #17654 [ci skip] 2015-05-30 09:05:52 -07:00
Kevin Deisz
777fa257aa Allow Enumerable#pluck to take a splat.
This allows easier integration with ActiveRecord, such that
AR#pluck will now use Enumerable#pluck if the relation is loaded,
without needing to hit the database.
2015-05-29 10:32:32 -04:00
Sean Griffin
343dad9617 Merge pull request #20364 from ernie/update-serialize-docs
Update docs for ActiveRecord `serialize`

[ci skip]
2015-05-29 08:21:16 -06:00
Ernie Miller
bbdcbbc98e Update docs for ActiveRecord serialize
For certain column types, using `serialize` is unnecessary, or the user
may get unexpected contents back from the DB adapter (which is handling
some basic deserialization for them). Call this out in the
documentation.

For background, see:

    https://gist.github.com/ernie/33f75f2294885b9806f9
    https://twitter.com/erniemiller/status/604262907442905090
2015-05-29 10:15:31 -04:00
Roque Pinel
9b986eadf4 Fix the shadowing warning for reflection 2015-05-28 19:10:52 -05:00
Sean Griffin
2f9d88954c Persist user provided default values, even if unchanged
This is a usability change to fix a quirk from our definition of partial
writes. By default, we only persist changed attributes. When creating a
new record, this is assumed that the default values came from the
database. However, if the user provided a default, it will not be
persisted, since we didn't see it as "changed". Since this is a very
specific case, I wanted to isolate it with the other quirks that come
from user provided default values. The number of edge cases which are
presenting themselves are starting to make me wonder if we should just
remove the ability to assign a default, in favor of overriding
`initialize`. For the time being, this is required for the attributes
API to not have confusing behavior.

We had to delete one test, since this actually changes the meaning of
`.changed?` on Active Record models. It now specifically means
`changed_from_database?`. While I think this will make the attributes
API more ergonomic to use, it is a subtle change in definition (though
not a backwards incompatible one). We should probably figure out the
right place to document this. (Feel free to open a PR doing that if
you're reading this).

/cc @rafaelfranca @kirs @senny

This is an alternate implementation of #19921.

Close #19921.

[Sean Griffin & Kir Shatrov]
2015-05-28 16:40:26 -06:00
Sean Griffin
a6e3cdae0c Allow proc defaults with the Attributes API
This is a variant implementation of the changes proposed in #19914.
Unlike that PR, the change in behavior is isolated in its own class.
This is to prevent wonky behavior if a Proc is assigned outside of the
default, and it is a natural place to place the behavior required by #19921
as well.

Close #19914.

[Sean Griffin & Kir Shatrov]
2015-05-28 16:26:49 -06:00
Rafael Mendonça França
233ceda594 Merge pull request #20331 from arunagw/arunagw-remove-unused-package-tasks
Remove unused package tasks
2015-05-28 18:48:21 -03:00
Shane Hender
87b07ef003 Give credit to extra contributor for Base.reload fix 2015-05-28 10:25:50 +01:00
Arun Agrawal
21b6b68f63 Remove unused package tasks
We are using `all:build` now.
2015-05-28 09:06:10 +02:00
Rafael Mendonça França
7cc9754209 Merge pull request #20196 from huoxito/preload-association-and-merges
Properly append preload / includes args on Merger
2015-05-28 01:52:14 -03:00
Washington Luiz
a01d164b94 Properly append preload / includes args on Merger
Couldn't find other way to get the association name from a given class
other than looping through `reflect_on_all_associations` reflections ..

Noticed this one while looking at this example:

```ruby
class Product < ActiveRecord::Base
  has_many :variants
  has_many :translations
end

class Translation < ActiveRecord::Base
  belongs_to :product
end

class Variant < ActiveRecord::Base
  belongs_to :product
end

class BugTest < Minitest::Test
  def test_merge_stuff
    product = Product.create! name: 'huhu'
    variant = Variant.create! product_id: product.id
    Translation.create! locale: 'en', product_id: product.id

    product_relation = Product.all
                              .preload(:translations)
                              .joins(:translations)
                              .merge(Translation.where(locale: 'en'))
                              .where(name: 'huhu')

    assert_equal variant, Variant.joins(:product).merge(product_relation).first
  end
end
```
2015-05-28 01:49:34 -03:00
Rafael Mendonça França
8cc5150065 Merge pull request #20041 from akshay-vishnoi/sqlite_collation
SQLite3: Add collation support for string and text columns
2015-05-28 00:38:15 -03:00
Rafael Mendonça França
add9500eb8 Add test to 57daaef 2015-05-28 00:37:21 -03:00
Jordan Raine
57daaef86a Allow Relation#compact using delegation 2015-05-28 00:35:04 -03:00
Akshay Vishnoi
3932912a59 Add collation support for string and text columns in SQLite3 2015-05-28 08:40:40 +05:30
Rafael Mendonça França
d81f147003 Merge pull request #20171 from georgeclaghorn/enums-in-fixtures
Allow the use of symbols or strings to specify enum values in test fixtures
2015-05-27 23:52:37 -03:00
Rafael Mendonça França
1ed92a2ee1 Merge pull request #19886 from henders/henders/reload_wipe_query_cache
Cause ActiveRecord::Base::reload to also ignore the QueryCache.
2015-05-27 23:45:55 -03:00
Rafael Mendonça França
c68e45dd3b Merge pull request #17654 from kamipo/strict_mode_explicitly
If specify `strict: :default` explicitly, do not set sql_mode.
2015-05-27 23:35:05 -03:00
George Claghorn
908cfef6e2 Resolve enums in test fixtures
Currently, values for columns backing Active Record enums must be
specified as integers in test fixtures:

    awdr:
      title: "Agile Web Development with Rails"
      status: 2

    rfr:
      title: "Ruby for Rails"
      status: <%= Book.statuses[:proposed] %>

This is potentially confusing, since enum values are typically
specified as symbols or strings in application code. To resolve the
confusion, this change permits the use of symbols or strings to specify
enum values:

    awdr:
      status: :published

It is compatible with fixtures that specify enum values as integers.
2015-05-27 21:48:58 -04:00
Rafael Mendonça França
27fdf4591d Merge pull request #20269 from wojobucco/master
Changed mysqldump to include sprocs and functions
2015-05-27 22:43:23 -03:00
Yves Senn
852460852c Merge pull request #20262 from arunagw/aa-remove-broken-unused-release-task
Remove broken and unused release task
2015-05-27 09:14:19 +02:00
Ryuta Kamizono
7961f4f776 If specify strict: :default explicitly, do not set sql_mode.
Related with #17370.
2015-05-26 17:44:24 -07:00
keepcosmos
995a473f0c add extend option on has_and_belongs_to_many. 2015-05-26 22:06:53 +09:00
Arun Agrawal
e56bdf3663 Remove unused variable
Was left in adfab2dcf4003ca564d78d4425566dd2d9cd8b4f
2015-05-26 11:04:47 +02:00
Yves Senn
adfab2dcf4 deprecate Relation#uniq use Relation#distinct instead.
See #9683 for the reasons we switched to `distinct`.

Here is the discussion that triggered the actual deprecation #20198.

`uniq`, `uniq!` and `uniq_value` are still around.
They will be removed in the next minor release after Rails 5.
2015-05-26 10:35:14 +02:00
Akshay Vishnoi
20c1484993 Remove .superclass_delegating_accessor. Refer #14271 2015-05-24 12:15:22 +05:30
Jonathan Worek
1b8adca358 Changed mysqldump to include sprocs and functions 2015-05-22 19:32:13 -04:00
Arun Agrawal
4194d052d8 Remove broken and unused release task
- We do release with release.rb
- There is no `rake/gemcutter`
2015-05-22 14:30:30 +02:00
Waynn Lue
f25997a9d9 "maybe" => "may be" 2015-05-21 20:11:41 -07:00
Manish shrivastava
6252d0aece updated Inline format at activerecord rdoc
For Inline formats, changed ` (single backticks)   to <tt> tag at active record rdoc as single backticks (`) don't work with rdoc. for inline format.
2015-05-20 19:15:33 +05:30
Santiago Pastorino
0f9ab4f348 Merge pull request #20219 from karanarora/Typo-fix
typo fix [ci skip]
2015-05-20 07:48:26 -03:00
karanarora
ec8b7a543e typo fix [ci skip] 2015-05-20 15:21:00 +05:30
Arun Agrawal
e00d63e2c6 Merge pull request #20217 from amitsuroliya/fix_netaddr_link
Fix NetAddr link [ci skip]
2015-05-20 10:34:05 +02:00
amitkumarsuroliya
ac20dd73ac Fix NetAddr link [ci skip] 2015-05-20 14:01:00 +05:30
Ronak Jangir
76fbfe9e6c Updated postgresql documentation link to use latest version [ci skip] 2015-05-20 14:00:31 +05:30
Aaron Patterson
0e12300c5e parent_reflection should store only a reflection object
we should ask the reflection for its name rather than storing the
reflection name in two places (an array and a reflection object)
2015-05-19 16:11:53 -04:00