Commit Graph

257 Commits

Author SHA1 Message Date
Gary S. Weaver
9bb27f7ffe #5523 Add ability for postgresql adapter to disable user triggers in disable_referential_integrity. 2012-12-18 10:46:16 -05:00
Pedro Padron
ba98dad113 Added support for validates_uniqueness_of in PostgreSQL array columns. Fixes: #8075. 2012-12-18 08:35:03 -02:00
Alexey
9a4a095ed7 AR supporting new intrange data type on PostgreSQL >= 9.2 2012-12-16 13:11:10 +02:00
Carlos Antonio da Silva
df9f9b7f3e Convert changelogs to 1.9 hash style and fix some formatting [ci skip] 2012-12-14 20:25:22 -02:00
Matthew M. Boedicker
8f59ffce67 Do not log the binding values for binary columns.
They tend to be large and not very useful in the log.
2012-12-14 12:19:17 -08:00
Matthew Robertson
a765c8426f Fix for has_many_through counter_cache bug
This commit fixes reported issue #7630 in which counter
caches were not being updated properly when replacing
has_many_through relationships
2012-12-14 10:03:05 -08:00
Yves Senn
349d460600 recognize migrations, in folders containing numbers and 'rb'.
Closes #8492
2012-12-13 09:08:32 +01:00
Carlos Antonio da Silva
2d3b1dabc9 Remove changelog entry from #8441 [ci skip]
This issue only happens on master due to internal AR refactorings, so
there is no need for a changelog entry.

The test was backported to 3-2-stable to ensure there won't be any regressions.
2012-12-11 08:33:58 -02:00
Rafael Mendonça França
d668544785 Add CHANGELOG entry for #6376.
Conflicts:
	activerecord/CHANGELOG.md
2012-12-10 17:48:31 -03:00
Rafael Mendonça França
9cce1ea2fd Allow users to choose the timestamp format in the cache key
This can be done using the class attribute cache_timestamp_format

Conflicts:
	railties/guides/source/configuring.textile
2012-12-10 17:48:26 -03:00
itzki
7efcc5d72f Fix decorating columns for serialized attributes 2012-12-10 14:44:24 +09:00
Jeremy Kemper
cff747d304 Move to the schema-migrations-metadata branch.
Pending work on graceful app upgrades.

Revert "Merge pull request #8439 from joshsusser/fixes"

This reverts commit ce8ac39338f86388e70356b3a470b3ea443802ae, reversing
changes made to b0e7b6f67c984d4b1502e801781ed75fad681633.

Revert "Merge pull request #8431 from joshsusser/schemadump"

This reverts commit 036d3e1c2b65c4b8cbd23de2e20ad67b9b756182, reversing
changes made to 0c692f4d121792117b6a71e5ed590a31c3b9d12e.

Revert "Merge branch 'joshsusser-master' into merge"

This reverts commit 0c692f4d121792117b6a71e5ed590a31c3b9d12e, reversing
changes made to 2e299fca715b083a60222a85e48f9d3b8dd8ce93.

Conflicts:
	activerecord/CHANGELOG.md
	activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
	activerecord/test/cases/schema_dumper_test.rb
2012-12-09 15:57:34 -07:00
Aaron Stone
97d06e8c4b Session variables for mysql, mysql2, and postgresql adapters can be set
in the new 'variables:' hash in each database config section in database.yml.
The key-value pairs of this hash will be sent in a 'SET key = value, ...'
query on new database connections.

The configure_connection methods from mysql and mysql2 into are
consolidated into the abstract_mysql base class.
2012-12-08 10:11:10 -08:00
Caike Souza
ad59260f70 Update AR Changelog with correct example using includes
These queries don't seem to work without the includes clause. [ci skip]
2012-12-08 08:16:13 -02:00
Carlos Antonio da Silva
8d02afeaee Rollback where.like and where.not_like
The real win with these chain methods is where.not, that takes care of
different scenarios in a graceful way, for instance when the given value
is nil.

    where("author.id != ?", author_to_ignore.id)
    where.not("author.id", author_to_ignore.id)

Both where.like and where.not_like compared to the SQL versions doesn't
seem to give us that much:

    Post.where("title LIKE 'ruby on%'")
    Post.where.like(title: 'ruby on%'")
    Post.where("title NOT LIKE 'ruby on%'")
    Post.where.not_like(title: 'ruby on%'")

Thus Rails is adding where.not, but not where.like/not_like and others.
2012-12-07 16:52:55 -02:00
Carlos Antonio da Silva
23b9cc8423 Merge pull request #8332 from amatsuda/ar_where_chain
Relation.where with no args can be chained with not, like, and not_like

Conflicts:
	activerecord/CHANGELOG.md
	activerecord/lib/active_record/relation/query_methods.rb
2012-12-07 00:46:06 -02:00
Carlos Antonio da Silva
0e67f793cd Unscope update_column(s) query to ignore default scope
When applying default_scope to a class with a where clause, using
update_column(s) could generate a query that would not properly update
the record due to the where clause from the default_scope being applied
to the update query.

    class User < ActiveRecord::Base
      default_scope where(active: true)
    end

    user = User.first
    user.active = false
    user.save!

    user.update_column(:active, true) # => false

In this situation we want to skip the default_scope clause and just
update the record based on the primary key. With this change:

    user.update_column(:active, true) # => true

Fixes #8436.
2012-12-06 23:17:56 -02:00
Carlos Antonio da Silva
1eaf3db804 Improve AR changelog 2012-12-06 22:24:00 -02:00
Steve Klabnik
b27f27d38d CHANGELOG for 78d5d6f.
It was pointed out by @giner that the CHANGELOG entry for 78d5d6f868
wasn't included. Here it is.
2012-12-06 10:43:33 -08:00
Aaron Patterson
0c692f4d12 Merge branch 'joshsusser-master' into merge
* joshsusser-master:
  style cleanup
  Add migration history to schema.rb dump
  Add metadata to schema_migrations

Conflicts:
	activerecord/CHANGELOG.md
	activerecord/lib/active_record/schema.rb
2012-12-05 12:13:49 -08:00
claudiob
019df98875 Replace comments' non-breaking spaces with spaces
Sometimes, on Mac OS X, programmers accidentally press Option+Space
rather than just Space and don’t see the difference. The problem is
that Option+Space writes a non-breaking space (0XA0) rather than a
normal space (0x20).

This commit removes all the non-breaking spaces inadvertently
introduced in the comments of the code.
2012-12-04 22:11:54 -08:00
kennyj
634d28e6cf Fix #8414. Performance problem with postgresql adapter primary_key function. 2012-12-05 02:19:03 +09:00
Yves Senn
db51704bd9 Do not instantiate intermediate AR objects when eager loading.
Closes #3313
2012-12-04 11:52:08 +01:00
Josh Susser
f02d2185eb Add migration history to schema.rb dump 2012-12-02 21:16:32 -08:00
Josh Susser
0a5afa229d Add metadata to schema_migrations
migrated_at: timestamp when migration run
fingerprint: md5 hash of migration source
name: filename without version or extension
2012-12-01 19:41:09 -08:00
Akira Matsuda
de75af7acc Relation.where with no args can be chained with not, like, and not_like
examples:

  Model.where.not field: nil
  #=> "SELECT * FROM models WHERE field IS NOT NULL

  Model.where.like name: 'Jeremy%'
  #=> "SELECT * FROM models WHERE name LIKE 'Jeremy%'

this feature was originally suggested by Jeremy Kemper https://github.com/rails/rails/pull/5950#issuecomment-5591330

Closes #5950
2012-11-30 01:18:18 +09:00
Jason Rush
89b5b31cc4 Added STI support to init and building associations
Allows you to do BaseClass.new(:type => "SubClass") as well as
parent.children.build(:type => "SubClass") or parent.build_child
to initialize an STI subclass. Ensures that the class name is a
valid class and that it is in the ancestors of the super class
that the association is expecting.
2012-11-29 05:50:34 +00:00
Rafael Mendonça França
ec17f0d352 Add CHANGELOG entries for the observes extraction
[ci skip]
2012-11-29 01:08:36 -02:00
Steve Klabnik
22df38ca33 Ensure that associations have a symbol argument.
Fixes #7418.
2012-11-28 13:39:42 -08:00
Rafael Mendonça França
f3aaf6d7d1 Use assert_nil instead of assert_equal 2012-11-28 12:02:11 -02:00
Alisdair McDiarmid
fc4e387d7a Don't call will_change! for datetime nil->"".
Setting a nil datetime attribute to a blank string should not cause the
attribute to be dirty.

Fix #8310
2012-11-25 11:24:27 +00:00
Carlos Antonio da Silva
d23c761f5a Fix changelog entry about fast_string_to_time fix
Introduced in 53ca22f2e11cd3050d75385bc31b6bb5055a2738.
Thanks @rochefort. [ci skip]
2012-11-24 09:30:18 -02:00
Rafael Mendonça França
b313bcba07 Merge pull request #8291 from senny/8265_build_with_polymorphic_association
prevent mass assignment of polymorphic type when using `build`

Conflicts:
	activerecord/CHANGELOG.md
2012-11-22 11:52:01 -02:00
Yves Senn
053bfa2304 prevent mass assignment of polymorphic type when using build
Closes #8265
2012-11-22 08:58:00 +01:00
Carlos Antonio da Silva
ad9983f625 Deprecate Relation#sum with a block.
To perform a sum calculation over the array of elements, use to_a.sum(&block).

Please check the discussion in f9cb645dfcb5cc89f59d2f8b58a019486c828c73
for more context.
2012-11-21 22:21:01 -02:00
Carlos Antonio da Silva
76a6bfd6c8 Revert "Yield only one argument instead of splatting."
This reverts commit f9cb645dfcb5cc89f59d2f8b58a019486c828c73.

Conflicts:
	activerecord/CHANGELOG.md

Revert "Allow blocks for count with ActiveRecord::Relation. Document and test that sum allows blocks"

This reverts commit 9cc2bf69ce296b7351dc612a8366193390a305f3.

Conflicts:
	activerecord/lib/active_record/relation/calculations.rb
2012-11-21 22:18:51 -02:00
Bogdan Gusiev
fa73cf7275 Fix postgresql adapter to handle bc timestamps correctly 2012-11-21 16:11:14 +02:00
Victor Costan
a8a60e9240 Postgresql doesn't accepts limits on text columns. 2012-11-20 10:59:40 -05:00
Rafael Mendonça França
0cc9c1255d Merge pull request #3023 from Tho85/preserve_sti_type
AR::Base.becomes should not change the STI type

Conflicts:
	activerecord/CHANGELOG.md
2012-11-18 23:25:13 -02:00
Jarek Radosz
1a782b2b63 Add rename_index to change_table. 2012-11-19 02:10:28 +01:00
Thomas Hollstegge
70fa756ddb AR::Base.becomes should not change the STI type
If you want to change the STI type too, use AR::Base.becomes! instead
2012-11-17 16:45:23 +01:00
Carlos Antonio da Silva
7411970398 Fix some AR changelog entries [ci skip] 2012-11-16 21:37:53 -02:00
Yves Senn
663d9ef670 #pluck can be used on a relation with select clause.
Closes #7551
2012-11-12 16:27:44 +01:00
Yves Senn
d5ac2801d9 cleanup, removed whitespace from CHANGELOG 2012-11-12 16:06:58 +01:00
Bogdan Gusiev
3cb0f3feed Do not create useless database transaction when building has_one association. 2012-11-10 15:30:20 +02:00
Yves Senn
710e371081 :counter_cache option for to support custom named counter caches. Closes #7993 2012-11-04 17:09:25 +01:00
Rafael Mendonça França
7042fe2f84 Deprecate passing a string as third argument of add_index
This was there due historical reasons since
7dc45818dc43c163700efc9896a0f3feafa31138 to give the user the
possibility to create unique indexes passing "UNIQUE" as the third
argument
2012-11-02 20:03:26 -02:00
Rafael Mendonça França
8fc52706c3 Raise an ArgumentError when passing an invalid option to add_index
Closes #8104
2012-11-02 19:00:58 -02:00
Alexis Bernard
a58cafeb3a Fix find_in_batches against string IDs when start option is not specified. 2012-10-31 15:39:24 +01:00
Nikita Afanasenko
e7e59a75aa Fix attributes_before_type_cast for serialised attributes.
Public method `attributes_before_type_cast` used to return internal AR structure (ActiveRecord::AttributeMethods::Serialization::Attribute), patch fixes this. Now behaves like `read_attribute_before_type_cast` and returns unserialised values.
2012-10-31 13:16:44 +04:00