Commit Graph

317 Commits

Author SHA1 Message Date
Brian Mathiyakom
8a4013ddd0 Fix issue #1272
Set reverse_order_value when asked to reverse_order().
Do the actual reversal in build_arel.
2011-06-01 18:30:14 +01:00
Jon Leighton
f4e3b70e9c Ensure that calculations properly override the select value even if it's set in the default scope. Fixes #1395. 2011-05-31 21:12:40 +01:00
Andrew White
09daaaa1e0 Add support for passing mass assignment roles to dynamic finders. Closes #1170. 2011-05-21 16:33:54 +01:00
Guillermo Iguaran
e7d600dcdb Syntax cleanup: for in => each 2011-05-19 22:55:37 -05:00
Fadzril Muhamad & Joseph Palermo
1db49ced45 Bug fixes:
- If doing a count on a relation that has an :include and a :join, it does a distinct even though it should not.
- When doing a count on a relation that has an :include, it always falls back to a old style left join when performing the count.  Looks like it was broken here:
b9599502c9
2011-05-12 04:05:24 +08:00
Jon Leighton
72a4893452 Merge pull request #451 from baroquebobcat/fixing_last_for_issue_371 2011-05-08 23:43:34 +01:00
Nick Howard
92c10760d7 Fix for #371
if a query contains a limit or an offset, ActiveRecord::FinderMethods#find_last had inconsistent behavior.

If the records were loaded, it returned the last record in the cached list.
If they were not, it reversed the order of the query and changed the limit to one.
If the earlier limit was less than the total matching the query in the db,
it would return a different record than if the records had been cached.

This commit changes find_last so that it loads the records when getting the
last record on a query containing a limit or an offset, which makes the behavior consistent.
2011-05-08 23:42:53 +01:00
Jon Leighton
8f10ccd311 Ensure that ORDER BY clauses from default scopes are not included in calculation queries. Fixes #406. 2011-05-08 23:31:16 +01:00
Aaron Patterson
850b3ca477 supporting nil when passed in as an IN clause 2011-04-29 11:01:59 -07:00
Josh Kalderimis
f9d5a7bb8c deprecated the use of the guard_protected_attributes argument with attributes= in AR in favor of assign_attributes(attrs, :without_protection => true) 2011-04-25 23:57:09 +02:00
Aaron Patterson
724a786677 stop using distinct on for the unique id queries. [#6450 state:resolved] 2011-04-21 22:47:13 -05:00
Aaron Patterson
eebb19c954 use index based substitution for bind parameters 2011-04-13 09:42:51 -07:00
Jon Leighton
8572ae6671 Evaluate default scopes at the last possible moment in order to avoid problems with default scopes getting included into other scopes and then being unable to remove the default part via unscoped. 2011-04-12 19:46:04 -07:00
Aaron Patterson
b53ffb35e0 stop using deprecated methods in arel 2011-04-11 15:50:05 -07:00
Emilio Tagua
b35617235d Use IM when trying to load records using ID.
Signed-off-by: José Valim <jose.valim@gmail.com>
2011-04-04 10:48:12 +02:00
Aaron Patterson
0471fc9f1c Merge branch 'master' into zomg
* master: (51 commits)
  order is not guaranteed by this select, so add an order and call first!
  oracle stores this with microseconds, so convert to seconds before comparing
  make sure that active connections are not cleared during test when an exception happens
  clearing active connections in the ConnectionManagement middleware if an exception happens
  proxy body responses so we close database connections after body is flushed
  Pass the proper method_name instead of hardcoding to action_name.
  Quote find_in_batches ORDER BY clause [#6620 state:resolved]
  Delegate first!, last!, any? and many? to scoped
  Dont call authenticate_or_request_with_http_basic twice
  Remove 'warning: ambiguous first argument' when running ActionPack tests
  Change exists? so that it doesn't instantiate records [#6127 state:resolved]
  Move mapper_test to the appropriate location
  Update the wildcard route to be non-greedy by default, therefore be able to match the (.:format) segment [#6605 state:resolved]
  Fix examples
  Added Base.http_basic_authenticate_with to do simple http basic authentication with a single class method call [DHH]
  make sure we have an active database connection before running each connection management test
  adding active_connections? to the connection pool for finding open connections
  adding active_connection? to the connection pool
  testing app delegation from the ConnectionManagement middleware
  namespacing connection management tests. ❤️
  ...
2011-03-29 17:38:43 -07:00
Andrew White
555d016389 Quote find_in_batches ORDER BY clause [#6620 state:resolved] 2011-03-29 17:24:55 +01:00
Andrew White
b155fdadf3 Change exists? so that it doesn't instantiate records [#6127 state:resolved] 2011-03-29 12:51:58 +01:00
Sebastian Martinez
fb21511040 Bring #reorder back
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2011-03-28 10:24:08 -03:00
Xavier Noria
9d9b873b95 removes unnecessary selfs, and mentions that first! and last! take no arguments in their API docs 2011-03-26 00:02:40 +01:00
Pratik Naik
25be204e3c No arguments for first! and last! 2011-03-25 22:30:36 +00:00
Josh Susser
65dce01091 comment typo fix 2011-03-25 12:28:37 -07:00
John Mileham
28c73f0123 Use Arel to build subquery. Adapt tests to changed fixtures. 2011-03-24 15:09:24 -04:00
John Mileham
b44a0ec153 Merge branch 'master' of github.com:rails/rails into count_behavior 2011-03-24 15:03:08 -04:00
Josh Susser
5214e73850 add #first! and #last! to models & relations 2011-03-24 09:55:51 -07:00
Aaron Patterson
2ef6270f8f Merge branch 'master' into fuuu
* master:
  Do not show optional (.:format) block for wildcard route [#6605 state:resolved]
  pushing id insertion and prefetch primary keys down to Relation#insert
  use prepared statements to fetch the last insert id
  escaping binary data encoding when inserting to sqlite3. Thanks Naruse! [#6559 state:resolved]
  schemas set by set_table_name are respected by the mysql adapter. [#5322 state:resolved]
  Reapply extensions when using except and only
  SJIS is an alias to Windows-31J in ruby trunk. Use SHIFT_JIS for this test
  Improved resolver docs a bit
  [action_view] docs for FileSystemResolver
  [action_view] added custom patterns to template resolver
2011-03-22 09:34:33 -07:00
Iain Hecker
96b9fc4400 Reapply extensions when using except and only 2011-03-21 10:29:45 -07:00
Jon Leighton
02a43f9f45 Resolve some TODO comments which I decided did not need anything done 2011-03-12 08:42:57 +00:00
Jon Leighton
28ed10d3f2 Merge branch 'master' into nested_has_many_through
Conflicts:
	activerecord/CHANGELOG
2011-03-05 22:58:48 +00:00
Aaron Patterson
74818a3543 use Arel::Table#alias rather than passing the :as parameter 2011-03-05 11:56:24 -08:00
Jon Leighton
735844db71 Merge branch 'master' into nested_has_many_through
Conflicts:
	activerecord/CHANGELOG
	activerecord/lib/active_record/association_preload.rb
	activerecord/lib/active_record/associations.rb
	activerecord/lib/active_record/associations/class_methods/join_dependency.rb
	activerecord/lib/active_record/associations/class_methods/join_dependency/join_association.rb
	activerecord/lib/active_record/associations/has_many_association.rb
	activerecord/lib/active_record/associations/has_many_through_association.rb
	activerecord/lib/active_record/associations/has_one_association.rb
	activerecord/lib/active_record/associations/has_one_through_association.rb
	activerecord/lib/active_record/associations/through_association_scope.rb
	activerecord/lib/active_record/reflection.rb
	activerecord/test/cases/associations/has_many_through_associations_test.rb
	activerecord/test/cases/associations/has_one_through_associations_test.rb
	activerecord/test/cases/reflection_test.rb
	activerecord/test/cases/relations_test.rb
	activerecord/test/fixtures/memberships.yml
	activerecord/test/models/categorization.rb
	activerecord/test/models/category.rb
	activerecord/test/models/member.rb
	activerecord/test/models/reference.rb
	activerecord/test/models/tagging.rb
2011-03-04 09:30:27 +00:00
John Mileham
d5994ee48a Change behavior of count(:limit => x, :offset => y) to limit/offset before counting. 2011-03-03 23:26:45 -05:00
Jon Leighton
b171b9e73d Move JoinDependency and friends from ActiveRecord::Associations::ClassMethods to just ActiveRecord::Associations 2011-02-28 22:12:43 +00:00
Aaron Patterson
f3e9cbc695 use an attribute rather than a SQL literal 2011-02-26 16:05:15 -08:00
Aaron Patterson
54a2bf6601 removing limits and offsets from COUNT queries unless both are specified. [#6268 state:resolved] 2011-02-25 15:38:59 -08:00
Xavier Noria
f41bf6938f merges docrails 2011-02-18 23:22:15 +01:00
Nicholas Rowe
9a9d895481 Fix Typos: remove several occurences of the the 2011-02-17 20:46:52 -05:00
Jon Leighton
1644663ba7 Split AssociationProxy into an Association class (and subclasses) which manages the association, and a CollectionProxy class which is *only* a proxy. Singular associations no longer have a proxy. See CHANGELOG for more. 2011-02-18 00:00:13 +00:00
Aaron Patterson
9c023cc4d2 explicitly allowing lolqueries 2011-02-16 15:11:48 -08:00
Aaron Patterson
ceb2f0f216 use the arel table rather than generating strings 2011-02-16 11:46:55 -08:00
Aaron Patterson
1dea7b5a61 no need for Array.wrap 2011-02-16 11:22:30 -08:00
Steven Fenigstein
9b188c5bfe removed an unnecessary second query when passing an ActiveRecord::Relation to a where clause. And added ability to use subselects in where clauses. 2011-02-16 09:54:09 -08:00
Ernie Miller
fbd917f50a Remove Relation#& alias for Relation#merge 2011-02-12 17:23:19 -08:00
Aaron Patterson
0b58a7ff42 limit() should sanitize limit values
This fixes CVE-2011-0448
2011-02-08 14:21:12 -08:00
Xavier Noria
8b5dc9caa5 Merge branch 'master' of git://github.com/lifo/docrails 2011-02-05 19:47:08 +01:00
Gabriel Horner
ac15647bf0 keep options titles consistent to "Options" 2011-02-03 23:51:06 -05:00
Ken Collins
95d5d9b6c4 The type_cast_calculated_value method will trust DB types before casting to a BigDecimal.
[#6365 state:committed]

Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2011-02-03 20:00:51 -02:00
Xavier Noria
236f1f52cd Merge branch 'master' of git://github.com/lifo/docrails 2011-01-20 10:33:38 +01:00
Jordi Romero
b31ef7ee83 document ActiveRecord's except and only
Document methods that allow easily override arel queries
2011-01-15 01:17:53 +01:00
Raimonds Simanovskis
f4f4964ce0 Always return decimal average of integer fields
In previous version if database adapter (e.g. SQLite and Oracle) returned non-String calculated values then type_cast_using_column converted decimal average value of intefer field to integer value. Now operation parameter is always checked to decide which conversion of calculated value should be done.
2011-01-10 15:51:32 -08:00