Commit Graph

535 Commits

Author SHA1 Message Date
Paul Nikitochkin
0aa95a71b0 Rescue invalid ip address exceptions on assign.
In order that set attribute should not be bang method
2013-08-14 21:04:31 +03:00
Ben Woosley
d35e900c00 Restore the use of #add_to_target for nested attribute updates on existing records, and don't bother updating the association if the update is going to be rejected anyway.
This requires adding a `skip_callbacks` argument to `#add_to_target`
so that we don't call the callbacks multiple times in this case,
which is functionally an application of existing association data,
rather than an addition of a new record to the association.
2013-08-12 02:37:39 -07:00
Dr.(USA) Joerg Schray
018697dece Fix interactions between :before_add callbacks and nested attributes assignment
Issue #1: :before_add callback is called when nested attributes assignment assigns to existing record if the association is not yet loaded
Issue #2: Nested Attributes assignment does not affect the record in the association target when callback triggers loading of the association
2013-08-12 02:37:39 -07:00
Eric Tipton
3a21870c6f Make 'enable_extension' revertible
If 'enable_extension' is used in a migration's 'change' method, use
'disable_extension' on down migration (and vice-versa).
2013-08-10 03:25:04 -04:00
Yves Senn
5ac2341fab cast hstore values on write to be consistent with reading from the db. 2013-08-08 07:27:30 +02:00
Yves Senn
806bc2add8 Fix multidimensional PG arrays containing non-string items 2013-08-07 20:28:14 +02:00
Rafael Mendonça França
4c1c2e6501 Add CHANGELOG entry for #11767
[ci skip]
2013-08-06 09:22:39 -03:00
schneems
f036239447 Create sqlite3 directory if not present
If the `db/` directory is not present on a remote machine it will blow up in unexpected ways with error messages that do not indicate there is a missing directory:

```
SQLite3::CantOpenException: unable to open database file
```

This PR checks to see if a directory exists for the sqlite3 file and if not creates it for you.

This PR is an alternative to #11692 as suggested by @josevalim
2013-08-05 12:10:52 -04:00
Carlos Antonio da Silva
0f8fe64c4e Use assert_nil instead of testing for equality 2013-08-02 09:45:12 -03:00
Rafael Mendonça França
e73f075689 Merge pull request #11714 from jetthoughts/11706_remove_bad_override_of_xml
Removed redundant xml override from pg adapter
2013-08-02 05:41:58 -07:00
Paul Nikitochkin
4371c5c4ec Removed redundant xml override from pg adapter
Closes: #11706
2013-08-02 11:04:50 +03:00
Rajarshi Das
36aaf46372 fix the changelog typo[ci skip] 2013-08-02 12:33:35 +05:30
Rafael Mendonça França
42f01e94e2 Merge branch 'revert-order-prepending'
Conflicts:
	activerecord/CHANGELOG.md
2013-07-30 00:05:47 -03:00
Rafael Mendonça França
92c5a2244e Revert change on ActiveRecord::Relation#order method that prepends new
order on the old ones

The previous behavior added a major backward incompatibility since it
impossible to have a upgrade path without major changes on the
application code.

We are taking the most conservative path to be consistent with the idea
of having a smoother upgrade on Rails 4.

We are reverting the behavior for what was in Rails 3.x and,
if needed, we will implement a new API to prepend the order clauses in
Rails 4.1.
2013-07-29 23:18:33 -03:00
sgrif
92a603387c Add ability to specify how a class is converted to Arel predicate
This adds the ability for rails apps or gems to have granular control
over how a domain object is converted to sql. One simple use case would
be to add support for Regexp. Another simple case would be something
like the following:

    class DateRange < Struct.new(:start, :end)
      def include?(date)
        (start..end).cover?(date)
      end
    end

    class DateRangePredicate
      def call(attribute, range)
        attribute.in(range.start..range.end)
      end
    end

    ActiveRecord::PredicateBuilder.register_handler(DateRange,
      DateRangePredicate.new)

More complex cases might include taking a currency object and converting
it from EUR to USD before performing the query.

By moving the existing handlers to this format, we were also able to
nicely refactor a rather nasty method in PredicateBuilder.
2013-07-28 13:12:20 -06:00
Ben Woosley
31a43ebc10 Don't allow quote_value to be called without a column
Some adapters require column information to do their job properly.
By enforcing the provision of the column for this internal method
we ensure that those using adapters that require column information
will always get the proper behavior.
2013-07-22 04:49:18 -07:00
Ben Woosley
c083dc22dd Tidy up the "Specified column type for quote_value" changes
This includes fixing typos in changelog, removing a deprecated
mocha/setup test require, and preferring the `column_for_attribute`
accessor over direct access to the columns_hash in the new code.
2013-07-22 04:39:38 -07:00
Alfred Wong
39b5bfe239 Specified column type for quote_value
When calling quote_value the underlying connection sometimes requires
more information about the column to properly return the correct quoted
value.

I ran into this issue when using optimistic locking in JRuby and the
activerecord-jdbcmssql-adapter. In SQLSever 2000, we aren't allowed to
insert a integer into a NVARCHAR column type so we need to format it as
N'3' if we want to insert into the NVARCHAR type. Unfortuantely, without
the column type being passed the connection adapter cannot properly return
the correct quote value because it doesn't know to return N'3' or '3'.

This patch is fairly straight forward where it just passes in the column
type into the quote_value, as it already has the ability to take in the column,
so it can properly handle at the connection level.

I've added the tests required to make sure that the quote_value method
is being passed the column type so that the underlying connection can
determine how to quote the value.
2013-07-22 04:39:35 -07:00
Vipul A M
0b6c1f082f rescue from all exceptions in ConnectionManagement#call
Fixes #11497

As `ActiveRecord::ConnectionAdapters::ConnectionManagement` middleware does not rescue from Exception (but only from StandardError),
the Connection Pool quickly runs out of connections when multiple erroneous Requests come in right after each other.

Recueing from all exceptions and not just StandardError, fixes this behaviour.
2013-07-22 14:44:33 +05:30
Yves Senn
c212cfecb1 Revert "Merge pull request #11120 from awilliams/ar_mysql2_boolean_quoting"
This reverts commit cb1d07e43926bcec95cb8b4a663ca9889173395a, reversing
changes made to 754a373e301d2df0b12a11083405252722bc8366.
2013-07-17 09:51:22 +02:00
awilliams
41bd94b7ef Unifies mysql and mysql2 casting of booleans
Using the mysql2 adapter, boolean values were sometimes being incorrectly cast
to 't' or 'f'. This changes the cast to match the mysql adapter behavior, ie 1 and 0.
2013-07-16 12:14:09 +02:00
Yves Senn
754a373e30 change_column for PG adapter respects :array option. 2013-07-16 10:56:22 +02:00
Arun Agrawal
0d4075fb47 Remove deprecation warning from attribute_missing
for attributes that are columns.
2013-07-15 19:18:36 +02:00
Paul Nikitochkin
e0d59e6219 #4566: Remove extra decrement of transaction level
`rollback_active_record_state!` tries to restore model state on `Exception`
by invoking `restore_transaction_record_state` it decrement deep level by `1`.

After restoring it ensure that states to be cleared
and level decremented by invoking `clear_transaction_record_state`,
which cause the bug: because state already reduced in `restore_transaction_record_state`.

Removed double derement of transaction level
and removed duplicated code which clear transaction state for top level.
2013-07-14 20:35:31 +03:00
kennyj
33354aa23e Reset @column_defaults when assigning . 2013-07-14 03:02:47 +09:00
Rafael Mendonça França
7948d78905 Merge pull request #11306 from jetthoughts/11288_remove_extra_queries_for_belongs_to_with_touch
#11288: Removed duplicated touching

Conflicts:
	activerecord/CHANGELOG.md
2013-07-06 17:33:26 -03:00
Yves Senn
b54ef7ebde Revert "Merge pull request #11299 from arunagw/disable_implicit_join_references_removed"
`disable_implicit_join_references=` was only deprecated on `master`,
not with rails 4.0. We can remove it after 4.1

This reverts commit 3c719ead414ffd29e71efce185698af979052abb, reversing
changes made to d5c3bf9722abd5733a769c8d789de3f74dbfb92d.
2013-07-05 16:44:32 +02:00
Paul Nikitochkin
1ecc3e83b6 #11288: Removed duplicated touching
if belongs to model with touch option on touch

Closes #11288
2013-07-05 17:13:54 +03:00
Arun Agrawal
6dd7f7c04e Remove deprecated ActiveRecord::Base.disable_implicit_join_references=. 2013-07-04 19:48:42 +02:00
Yves Senn
8ee599ea86 Remove deprecated nil-passing to SchemaCache methods. 2013-07-04 10:40:52 +02:00
Yves Senn
6d554b263b Remove deprecated block filter from ActiveRecord::Migrator#migrate. 2013-07-04 10:09:12 +02:00
Yves Senn
685631285f Remove deprecated String constructor from ActiveRecord::Migrator. 2013-07-04 09:49:03 +02:00
Arun Agrawal
50cbc03d18 Remove deprecated scope use without passing a callable object.
Removed tests from deprecated code.
2013-07-03 23:23:11 +02:00
Arun Agrawal
9105c59af0 Remove deprecated transaction_joinable=
in favor of `begin_transaction`
with `:joinable` option.
2013-07-03 23:23:11 +02:00
Arun Agrawal
b23501112e Remove deprecated decrement_open_transactions. 2013-07-03 23:23:11 +02:00
Arun Agrawal
51c97e7e19 removed deprecated increment_open_transactions 2013-07-03 23:23:11 +02:00
Yves Senn
fca29750e4 remove deprecated PostgreSQLAdapter#outside_transaction? method. 2013-07-03 20:49:57 +02:00
Vipul A M
28d1d3f0fb Remove deprecated ActiveRecord::Fixtures.find_table_name in favour of ActiveRecord::Fixtures.default_fixture_model_name. 2013-07-03 15:28:05 +05:30
Neeraj Singh
0e8027fb34 Removed deprecated method columns_for_remove 2013-07-03 08:21:10 +05:30
Francesco Rodriguez
341b73965d Remove deprecated SchemaStatements#distinct 2013-07-02 16:41:17 -05:00
Yves Senn
eb5b7a8ced deprecated ActiveRecord::TestCase is no longer public.
/cc @tenderlove
2013-07-02 22:12:17 +02:00
Neeraj Singh
0e3700364c Dropped deprecated option :restrict for :dependent in associations 2013-07-03 00:56:20 +05:30
Neeraj Singh
8ef2463807 Removed support for deprecated delete_sql in associations. 2013-07-03 00:10:55 +05:30
Neeraj Singh
39ee74c405 Removed support for deprecated insert_sql in associations. 2013-07-02 23:38:46 +05:30
Neeraj Singh
d80334488f Removed support for deprecated finder_sql in associations. 2013-07-02 22:08:42 +05:30
Rafael Mendonça França
f875d319ad Add CHANGELOG enty for #11235 2013-07-02 11:50:15 -03:00
Neeraj Singh
4bf1ecd6d8 Removed support for deprecated counter_sql 2013-07-02 17:54:16 +05:30
Rafael Mendonça França
260c2015b3 Merge pull request #10604 from neerajdotname/delete_all_should_not_call_callbacks
Do not invoke callbacks when delete_all is called

Conflicts:
	activerecord/CHANGELOG.md
2013-07-01 23:41:32 -03:00
Neeraj Singh
71db2420a1 calling default_scope without a proc will raise ArgumentError
Calling default_scope without a proc will now raise `ArgumentError`.
2013-07-02 08:07:33 +05:30
Neeraj Singh
cfc54e417d Removed deprecated method type_cast_code from Column 2013-07-02 07:37:51 +05:30