Commit Graph

3573 Commits

Author SHA1 Message Date
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
6a185aa0a8 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:41:37 -03:00
Rafael Mendonça França
9639f65af5 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:40:24 -03:00
Arthur Neves
fc59e997d7 add regression test for set_inverse_instance on add_to_target 2013-10-04 11:15:55 -04: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
Arthur Neves
e1bb9fc671 on tests: dont always touch firm on validate 2013-09-25 19:50:42 -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
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
Rafael Mendonça França
1463fbeafb Fix broken test
quote_value is called on the object not the class
2013-07-24 16:21:37 -03:00
Ben Woosley
b4dea61a42 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.

Conflicts:
	activerecord/CHANGELOG.md
	activerecord/lib/active_record/locking/optimistic.rb
2013-07-24 13:20:30 -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
66cba60103 Use Ruby 1.8 syntax 2013-07-15 17:44:49 -03:00
Yves Senn
1c2545a455 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

Conflicts:
	activerecord/CHANGELOG.md
2013-07-15 15:49:42 -03:00
Rafael Mendonça França
29106ce99c Skip connection url test when the machine is using socket configuration.
The connection url parssing don't accept the socket option
2013-07-06 17:10:55 -03:00
Yves Senn
63d4894a58 Merge pull request #11019 from tkhr/test_case_for_issue_10393
Add test case for issue #10393 and fix warning message
2013-06-25 23:42:35 -07:00
Yves Senn
cacfa8e3fb build fix, fall back to old hash syntax 2013-06-26 08:33:44 +02: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
Yves Senn
b23e0d6639 Merge pull request #9893 from JonRowe/add_test_to_assert_association_doesnt_overwrite
Add a test to assert autosaving associations doesn't overwrite id accessor methods
2013-06-25 22:45:36 -07: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
Aaron Patterson
20daaf4e2a adding a test for #10830 2013-06-05 17:14:55 +09:00
Arun Agrawal
b75c8e58ab Using 1.8.7 syntax for 3-2-stable 2013-05-24 11:20:20 +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
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
Xavier Noria
4fa860728f Merge pull request #10555 from dasch/dasch/3-2-stable
Don't try to EXPLAIN select_db calls
2013-05-10 08:05:54 -07:00
Daniel Schierbeck
a33d320cf4 Don't try to EXPLAIN select_db calls 2013-05-10 16:50:35 +02:00
Arun Agrawal
de5b89ddc9 Fixed pluck to be working with selects.
See #9777 for details.

Previously pluck is not returning what we wanted to
Added a test also to make sure it's working fine.
 
This will also fix the build for 1.8.7 as we 
were doing some sort on hash.

Thanks @pixeltrix for helping me out.

Thanks @linduxed for pairing with me.
2013-05-10 16:05:05 +02:00
Rafael Mendonça França
84c69a1653 Revert "Merge pull request #8209 from senny/backport_8176"
This reverts commit 7240202784, reversing
changes made to e4e2bcce75.

Conflicts:
	activerecord/CHANGELOG.md
	activerecord/lib/active_record/relation/calculations.rb
	activerecord/test/cases/calculations_test.rb

Reason: This caused a regression since it changed the behavior in a
stable release.

Fixes #9777
2013-05-08 23:34:24 -03:00
Rafael Mendonça França
f8c4a31e0b Merge pull request #10489 from greenriver/ar_counter_cache_multiple_destroy
Confirm a record has not already been destroyed before decrementing counter cache

Conflicts:
	activerecord/CHANGELOG.md

Conflicts:
	activerecord/CHANGELOG.md
	activerecord/lib/active_record/associations/builder/belongs_to.rb
2013-05-06 22:44:01 -03:00
Janko Marohnić
5519468523 Fix ActiveRecord::Store not tracking changes 2013-04-29 20:39:52 +02:00
Aaron Patterson
9d7a748a51 adding test for the symbol refs 2013-04-26 16:47:27 -07:00
Erik Peterson
a6d9e16e41 Correctly parse bigint defaults in PostgreSQL, Backpost #10098.
Conflicts:

	activerecord/CHANGELOG.md
	activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
	activerecord/test/cases/schema_dumper_test.rb
2013-04-11 10:11:18 +02:00
Aaron Patterson
536f316cd3 Merge branch '3-2-later' into 3-2-stable
* 3-2-later:
  adding test for CVE
2013-04-09 09:22:42 -07:00
Carlos Antonio da Silva
e59f3809ef Merge pull request #7792 from seejee/chained_scopes_preload_properly
Fixes Issue #7490: Chained scopes will preload properly
2013-04-03 15:43:59 -07:00
Chris Geihsler
453c7d6c47 Chained scopes will be preloaded properly. Fixes #7490 2013-04-03 18:41:12 -04:00
Fred Wu
55e2954703 Don't reset inheritance_column when setting explicitly.
This is backported from master (cdfcbc4).
2013-03-27 09:12:31 +11:00
Jon Rowe
0c96169f59 test case to assert that associations do not overwrite after create, fixes #9310 2013-03-24 12:32:11 +13:00