Commit Graph

5871 Commits

Author SHA1 Message Date
Rob Sanheim
0afd326c36 Move commit exception handling to a method so we can override
It looks like these methods all get included into the AbstractAdapter,
and then in github/github we have our own Adapter as an internal gem.

So this should be easy enough to override in our vendor'ed adapter.

This will allow us to still grab errors that happen in `after_commit`
which would normally be swallowed in Rails 3.0 (and beyond).

Conflicts:
	activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb
2014-09-26 16:25:08 +10:00
Rob Sanheim
c957f5f609 only _run_commit_callbacks when destroyed or persisted:
should fix issues with commit callbacks getting called when the record
is not persisted (yet) in a inner transaction or due to some other edge
case.

see also caabed6c76

Conflicts:
	activerecord/lib/active_record/transactions.rb
2014-09-26 16:19:59 +10:00
Charlie Somerville
78e6c36ba3 convert times to local when quoting for db 2014-09-19 17:50:29 +10:00
Arthur Neves
7cbeae9a5c Make sure transaction state resets after commit
[fixes #12566]

Conflicts:
	activerecord/test/cases/transaction_callbacks_test.rb
2014-09-18 14:23:36 +10:00
Rafael Mendonça França
53c845cb18 Preparing for 3.2.19 release 2014-07-02 12:55:09 -03:00
Rafael Mendonça França
1f2192e46d Check against bit string values using multiline regexp
Fix CVE-2014-3482.
2014-07-02 12:49:01 -03:00
Rafael Mendonça França
bbec7d72be Merge branch '3-2-sec' into 3-2-stable
Conflicts:
	actionpack/CHANGELOG.md
2014-05-06 13:31:07 -03:00
Rafael Mendonça França
4e8f1d2588 Preparing for 3.2.18 release 2014-05-06 11:33:10 -03:00
Rafael Mendonça França
a3bda38467 Merge branch '3-2-17' into 3-2-stable
Conflicts:
	actionpack/CHANGELOG.md
2014-02-18 15:57:32 -03:00
Rafael Mendonça França
666e9f65bd Preparing for 3.2.17 release 2014-02-18 15:16:57 -03:00
Chris Maddox
1805682efa Update Session Store Documentation
session_id doesn't need to be a text column, just string (VARCHAR)
2013-12-13 17:02:16 -08:00
Aaron Patterson
64226302d8 updating the changelog 2013-12-02 16:17:19 -08:00
Aaron Patterson
2a0c4403fd bumping to 3.2.15 2013-10-15 11:48:53 -07:00
Aaron Patterson
e3abd78ee5 bumping to rc3 2013-10-11 14:16:06 -07:00
Rafael Mendonça França
38aefa51c3 Revert "Merge pull request #12413 from arthurnn/inverse_of_on_build"
This reverts commit ccd11d5891, reversing
changes made to 54c05acdba.

Reason: This caused a regression when the associated record is created
in a before_create callback. See
https://github.com/rails/rails/pull/12413#issuecomment-25848163
2013-10-10 14:55:12 -03:00
Rafael Mendonça França
fbc69ac560 Revert "Merge pull request #12443 from arthurnn/add_inverse_of_add_target"
This reverts commit 7ed5bdc834, reversing
changes made to 31c79e291f.

Reason: this caused a regression when the associated record is creted in
a before_create callback.

See https://github.com/rails/rails/pull/12413#issuecomment-25848163
2013-10-10 14:55:07 -03:00
Aaron Patterson
5ede19b772 bumping to rc2 2013-10-04 13:46:35 -07:00
Rafael Mendonça França
73dff26125 Merge pull request #12443 from arthurnn/add_inverse_of_add_target
Add inverse of add target
2013-10-04 13:58:36 -03:00
Aaron Patterson
5e277c8208 bumping version to 3.2.15.rc1 2013-10-03 11:52:44 -07:00
Aaron Patterson
31c79e291f Merge pull request #12084 from Ben-M/3-2-stable
Fix STI scopes using benolee's suggestion. Fixes #11939
2013-10-03 11:14:19 -07:00
Arthur Neves
679860400f Move set_inverse_instance to association.build_record
[fixes #10371]
2013-09-30 17:20:26 -04:00
Arthur Neves
fed6ac9c66 fix inverse_of when find_or_initialize_by_*
inverse_of relation was not being set when calling find_or_initialize_by_ and the entry was
found on the db.
2013-09-26 14:55:10 -04:00
Rafael Mendonça França
fdc3c08e55 Merge pull request #12359 from arthurnn/inverse_on_callbacks
Make sure inverse_of is visible on the has_many callbacks
Conflicts:
	activerecord/CHANGELOG.md
	activerecord/test/models/company.rb
2013-09-25 16:31:00 -03:00
Eugene Kalenkovich
c9642e31b1 Fix FinderMethods#last unscoped primary key
Fixes table.joins(:relation).last(N) breaking on sqlite

Conflicts:
	activerecord/CHANGELOG.md
	activerecord/test/cases/finder_test.rb
2013-09-12 14:08:02 -03:00
Arthur Neves
f0301e3de6 on SchemaCache use the connection getter instead of the obj given 2013-09-09 13:47:07 -04:00
Ben Maraney
cf1904f65b Fix STI scopes using benolee's suggestion. Fixes #11939 2013-08-30 12:58:41 +03:00
Kassio Borges
0ec701d50b Load fixtures from linked folders 2013-08-05 16:52:12 -03:00
Alfred Wong
33e1604b3e 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.

Conflicts:
	activerecord/CHANGELOG.md
	activerecord/lib/active_record/locking/optimistic.rb
2013-07-24 13:18:21 -03:00
90yukke
b289519f4f Fix merge error when Equality LHS is non-attribute.
This is reworking of rails/rails/pull/7380 made for rails 3.
2013-07-23 10:38:00 +03:00
Rafael Mendonça França
2fcd13eff2 Preparing for 3.2.14 release 2013-07-22 12:05:41 -03:00
Rafael Mendonça França
a96df04aac Preparing for 3.2.14.rc2 release 2013-07-16 13:00:33 -03:00
Yves Senn
2ae2728d78 Merge pull request #11451 from jetthoughts/11450_do_not_resave_destroyed_association
Do not re-save destroyed association on saving parent object
Conflicts:
	activerecord/lib/active_record/autosave_association.rb
2013-07-15 15:48:43 -03:00
Rafael Mendonça França
facfc24f25 Preparing for 3.2.14.rc1 release 2013-07-12 21:06:50 -03:00
Rafael Mendonça França
d704c1cb98 Do not shallow the original exception in exec_cache
when result_error_field is not defined on result raise the original
exception.

Fixes #11260
2013-07-09 07:41:32 -03:00
chapmajs
839efc5b6d Allow global override of default STI inheritance column
This change fixes a bug by which 3.2-STABLE users can't globally override the default STI inheritance column with `ActiveRecord::Base.inheritance_column = 'some_column'`. 3.2-STABLE users are forced to use a deprecated method or monkey patch it otherwise.

Test case written by tkhr <takehiro0740@gmail.com>.
2013-06-26 14:55:18 +09:00
Carlos Antonio da Silva
07c6262c25 Merge pull request #10373 from janko-m/fix-store-accessor
Fix a bug in ActiveRecord::Store accessors
2013-06-25 22:03:01 -03:00
Yves Senn
27b3883846 Revert "Revert "Merge pull request #10901 from armstrjare/fix_query_null_foreign_key_on_new_record_collection_ids_reader""
This reverts commit 5009b07887.

Also updated the CHANGELOG and adjusted the test-case to match the one on master.
2013-06-25 18:07:06 +02:00
Yves Senn
5009b07887 Revert "Merge pull request #10901 from armstrjare/fix_query_null_foreign_key_on_new_record_collection_ids_reader"
This reverts commit 6675d71318, reversing
changes made to 919d1a19d5.

I missed to check the target branch and wrongly merged it into 3-2-stable directly.
2013-06-22 12:15:42 +02:00
Yves Senn
6675d71318 Merge pull request #10901 from armstrjare/fix_query_null_foreign_key_on_new_record_collection_ids_reader
Fixes CollectionAssociation#ids_reader returning incorrect ids for new records
2013-06-22 03:11:19 -07:00
Jared Armstrong
c2377f72d2 Fixes CollectionAssociation#ids_reader returning incorrect ids for new records 2013-06-21 13:03:54 +12:00
Yves Senn
a51d4e6c25 Merge pull request #10925 from senny/10917_test_to_prevent_regression
regression test + mysql2 adapter raises correct error if conn is closed.
Conflicts:

	activerecord/CHANGELOG.md
2013-06-15 14:51:17 +02:00
Andrew White
8799cfa72d Restore rescue block for when IM is enabled 2013-05-24 13:02:19 +01:00
Arun Agrawal
0e14973a33 It's scoped in 3-2-stable!
scope => scoped
2013-05-24 11:20:43 +02:00
Rafael Mendonça França
d29399061e Merge pull request #10713 from senny/10693_fix_primary_key_option_on_has_many
Fix the `:primary_key` option for `has_many` associations.
Conflicts:
	activerecord/CHANGELOG.md
	activerecord/lib/active_record/associations/has_many_association.rb
2013-05-23 18:45:12 -03:00
Johnny Holton
c2362461cd destroys association records before saving/inserting new association records
This is a backport of #10417

fixes bug introduced by  #3329
These are the conditions necessary to reproduce the bug:
- For an association, autosave => true.
- An association record is being destroyed
- A new association record is being created.
- There is a unique index one of the association's fields.
- The record being created has the same value as the record being
destroyed on the indexed field.

Before, the deletion of records was postponed until after all
insertions/saves.  Therefore the new record with the identical value in
the indexed field caused a non-unique value error to be thrown at the
database
level.

With this fix, the deletions happen first, before the insertions/saves.
Therefore the record with the duplicate value is gone from the database
before the new record is created, thereby avoiding the non-uniuqe value
error.
2013-05-18 18:20:52 -04:00
Ben Woosley
23c656c1bc Backport a super-simplified version of #6792, fixing
that #exists? and others can produce invalid SQL: "SELECT DISTINCT DISTINCT"

The combination of a :uniq => true association and the #distinct call
in #construct_limited_ids_condition combine to create invalid SQL, because
we're explicitly selecting DISTINCT, and also sending #distinct on to AREL,
via the relation#distinct_value.

Where #6792 was the forever fix, this is the minimal fix. Instead of
properly indicating the distinctness of the query through #uniq_value alone,
we use a literal select statement and set #uniq_value to always be falsey
2013-05-14 16:03:17 +02:00
Rafael Mendonça França
442b7c8ccf Merge pull request #7695 from benolee/backport_cc7dd66_and_c0ba0f0
backport runner fixes to 3-2-stable

Conflicts:
	railties/CHANGELOG.md
2013-05-12 15:13:47 -03:00
Andrew Horner
c09829e03d Preserve context for joins while merging relations
This is a backport of #10164, already merged into
master. The issue is described in lengthy detail
in issues #3002 and #5494.
2013-05-11 22:41:47 -05:00
Daniel Schierbeck
ddaa5d5181 Don't try to EXPLAIN select_db calls
Now with a non-broken test.
2013-05-12 00:33:01 +02:00
Xavier Noria
0549ebea22 Revert "Don't try to EXPLAIN select_db calls"
Reason: This was backported, but the test does not pass as is.

This reverts commit a33d320cf4.
2013-05-11 01:28:06 +02:00