Jeremy Kemper
bd3cc6bfff
Remove quoted_string_prefix entirely since PostgreSQL was the only database adapter relying on it.
2010-04-24 16:27:20 -07:00
Evan Phoenix
a307fd6bd3
Don't depend on order of elements in Set
2010-03-22 10:00:03 -07:00
Jeremy Kemper
949c8c0d0e
Don't publicize with_scope for tests since it may shadow public misuse
2009-12-28 14:07:23 -08:00
Pratik Naik
1c26ba486c
Add Model.from and association_collection#from finder methods
2009-12-28 03:59:44 +05:30
Pratik Naik
85770ec713
Make Model.find_or_create_by_* and find_or_initialize_by_* use relations and remove method caching
2009-12-27 14:46:38 +05:30
Pratik Naik
8829d6ecc6
Make Model.find_by_* and Model.find_all_by_* use relations and remove dynamic method caching
2009-12-27 13:17:29 +05:30
Pratik Naik
cc753eaf58
Replace Model.first(options) with new finder methods inside tests
2009-12-27 01:50:03 +05:30
Pratik Naik
f374150698
Ensure Model.scoped adds type conditions for STI models
2009-12-27 00:11:31 +05:30
Emilio Tagua
9520143159
Merge commit 'rails/master'
...
Conflicts:
activerecord/test/cases/adapter_test.rb
activerecord/test/cases/method_scoping_test.rb
2009-08-08 19:14:35 -03:00
Josh Sharpe
54e7f5ba43
Tidy up the AR tests, removing duplicates and making tests clearer / more focussed.
...
Signed-off-by: Michael Koziarski <michael@koziarski.com>
[#2774 state:committed]
2009-08-08 14:53:35 +12:00
Raimonds Simanovskis
5f0c425e8d
Some databases (e.g. Oracle) does not allow "AS" between table name and table alias name, for others it is optional
2009-08-06 23:41:00 +03:00
Emilio Tagua
ae175a5354
Merge commit 'rails/master'
2009-08-05 14:52:07 -03:00
Joshua Peek
f8d3c72c39
Extract generic attribute method generation to AMo
2009-08-04 23:36:05 -05:00
Geoff Buesing
6f97ad07de
quoted_date converts time-like objects to ActiveRecord::Base.default_timezone before serialization. This allows you to use Time.now in find conditions and have it correctly be serialized as the current time in UTC when default_timezone == :utc [ #2946 state:resolved]
2009-08-03 22:03:47 -05:00
Emilio Tagua
0e0866e056
Introduced ActiveRecord::Relation, a layer between an ARel relation and an AR relation
2009-07-21 20:21:03 -03:00
Pratik Naik
45e6f19925
Revert "Revert "Generate proper :counter_sql from :finder_sql when there is a newline character immediately following 'SELECT' [ #2118 state:resolved]""
...
This reverts commit 80f1f863cd0f9cba89079511282de5710a2e1832.
The feature doesn't work on Postgres, so don't test it on Postgres.
Also, Postgres compatibility is irrelevant to the ticket/patch in question.
2009-07-01 00:02:00 +01:00
Yehuda Katz + Carl Lerche
80f1f863cd
Revert "Generate proper :counter_sql from :finder_sql when there is a newline character immediately following 'SELECT' [ #2118 state:resolved]"
...
This reverts commit 4851ca9e13a4317342df02ae25b1929340523f7a.
The tests do not pass for postgresql.
2009-06-22 12:04:02 -07:00
Patrick Joyce
4851ca9e13
Generate proper :counter_sql from :finder_sql when there is a newline character immediately following 'SELECT' [ #2118 state:resolved]
...
Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
2009-06-21 22:07:23 +01:00
Emilio Tagua
28f5cfe066
Add missing model and fixtures to finder_test [ #2671 state:resolved]
...
Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
2009-05-18 15:58:25 +02:00
Peter Marklund
afcbdfc15f
Changed ActiveRecord::Base#exists? to invoke find_initial so that it is compatible with, and doesn't lose, :include scopes (references to eager loaded tables)
...
Signed-off-by: Michael Koziarski <michael@koziarski.com>
[#2543 state:committed]
2009-05-14 20:42:00 +12:00
Jeremy Kemper
e8550ee032
Cherry-pick core extensions
2009-05-13 12:00:15 -07:00
Emilio Tagua
a841cd2503
Fix models load order to be able to run unit tests.
...
[#2550 state:committed]
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
2009-04-23 16:02:11 -07:00
Jeremy Kemper
1c36172c13
Ruby 1.9 compat: rename deprecated assert_raises to assert_raise.
...
[#1617 state:resolved]
2009-03-08 13:11:58 -07:00
Will Bryant
7fb7b48a1f
Allow :having conditions to be sanitized like regular :condition. [ #2158 state:resolved]
...
Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
2009-03-06 22:29:53 +00:00
Pratik Naik
4863634a15
Ensure supplie :from has precedence over scoped :from [ #1370 state:resolved]
2009-03-06 18:36:30 +00:00
Will Bryant
9991868d85
support end-exclusive ... Ranges in SQL hash condition sanitization properly
...
Signed-off-by: Michael Koziarski <michael@koziarski.com>
[#1865 state:committed]
2009-02-06 13:43:02 +13:00
Scott Taylor
5a8f764661
Add ActiveRecord::Base.exists? with no args [ #1817 state:committed]
...
Signed-off-by: David Heinemeier Hansson <david@loudthinking.com>
2009-02-05 20:51:06 +01:00
Jeremy Kemper
278186534c
Bump mocha requirement for Ruby 1.9 compat. Remove uses_mocha.
2009-02-03 18:40:22 -08:00
miloops
97403ad5fd
Add :having option to find, to use in combination with grouped finds. Also added to has_many and has_and_belongs_to_many associations.
...
Signed-off-by: Michael Koziarski <michael@koziarski.com>
[#1028 state:committed]
2008-12-01 20:22:31 +01:00
Ken Miller
8a77c4abfa
Fixed issue where block is not called on the very first invocation of a find_or_create_by_ automatic finder.
...
[#1224 state:committed]
2008-10-24 21:35:05 +02:00
Eloy Duran
8d337e9ec2
Dynamic finders should use the ActiveRecord::Base::find method instead of ::find_initial, :find_last, and ::find_all.
...
This is so when people override ActiveRecord::Base::find, the new ::find method will also be invoked by the dynamic finders.
Associations for instance do go through ::find, so this makes it more consistent.
Also removed the unnecessary deprecation silence blocks.
Signed-off-by: Michael Koziarski <michael@koziarski.com>
[#1162 state:committed]
2008-10-03 21:28:11 +02:00
Pivotal Labs
487758b3b8
Allowed passing arrays-of-strings to :join everywhere. Merge duplicate join strings to avoid table aliasing problems.
...
Signed-off-by: Michael Koziarski <michael@koziarski.com>
[#1077 state:committed]
2008-09-24 13:26:06 +02:00
Manfred Stienstra
1585a7ed02
Change all calls to String#chars to String#mb_chars.
2008-09-21 18:01:15 +02:00
miloops
646b5bfa61
Use select and change test so new tests can work on postgres.
...
Signed-off-by: Michael Koziarski <michael@koziarski.com>
2008-09-12 12:27:03 +02:00
miloops
a37c5ae961
Improve test coverage when using the group option in find, has_many or has_and_belongs_to_many.
...
Signed-off-by: Michael Koziarski <michael@koziarski.com>
2008-09-11 22:51:57 +02:00
Manfred Stienstra
babbc1580d
Fix ActiveRecord::Base.quote_bound_value for ActiveSupper::Multibyte::Chars values.
...
- Adds String#acts_like_string?
- Adds Chars#acts_like_string?
Signed-off-by: Michael Koziarski <michael@koziarski.com>
[#1029 state:committed]
2008-09-11 22:51:26 +02:00
Tarmo Tänav
14d1560e85
Fixed test_find_last_by_one_attribute_caches_dynamic_finder for postgresql 8.3
...
Signed-off-by: Michael Koziarski <michael@koziarski.com>
2008-09-10 13:40:45 +02:00
miloops
567392bff3
Added find_last_by dynamic finder [status:committed #762 ]
...
Signed-off-by: David Heinemeier Hansson <david@loudthinking.com>
2008-09-09 23:44:52 -05:00
Josh Susser
1092c181b5
add dynamic finder bang version to raise RecordNotFound
...
[#905 state:resolved]
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
2008-08-25 23:33:16 -07:00
Josh Susser
143f5fbb21
refactor dynamic finder name matching into its own class
...
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
2008-08-25 23:32:20 -07:00
Pratik Naik
cd994eff9a
Allow conditions on multiple tables to be specified using hash.
...
Examples:
User.all :joins => :items, :conditions => { :age => 10, :items => { :color => 'black' } }
Item.first :conditions => { :items => { :color => 'red' } }
Note : Hash key in :conditions is referring to the actual table name or the alias defined in query.
2008-06-28 01:27:51 +01:00
Tarmo Tänav
509374ebe2
Named bind variables can now be used with postgresql-style typecasts
...
For example :conditions => ['stringcol::integer = :var', { :var => 10 }]
will no longer raise an exception about ':integer' having a missing value.
2008-06-22 16:16:06 -07:00
Tarmo Tänav
c5d37c0662
Fix tests for postgres 8.3.x
...
Made test_with_limiting_with_custom_select not dependent on database
default order. Fixed tests with non-US monetary locale. The monetary
type is fixed precision so it should not expect the database to
return a float.
Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
2008-05-26 00:45:42 +01:00
Pratik Naik
802034ff5f
DRY associations code and improve eager loading tests.
2008-05-15 13:47:05 +01:00
John Devine
b28b54cab0
Make sure needed table joins are included :select option. [ #110 state:resolved]
...
Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
2008-05-15 13:42:28 +01:00
John Devine
8ded457b1b
Added logic to associations.rb to make sure select_for_limited_ids
...
includes joins that are needed to reach tables listed in the :order
or :conditions options if they are not joined directly to the main
active_record table.
Signed-off-by: Michael Koziarski <michael@koziarski.com>
[#109 state:resolved]
2008-05-06 21:47:10 +12:00
Pratik Naik
4f39382a2f
Ensure that respond_to? considers dynamic finder methods. Closes #11538 . [floehopper]
...
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@9235 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2008-04-06 22:26:15 +00:00
David Heinemeier Hansson
c10b2255b5
Fixed that ActiveRecord#Base.find_or_create/initialize would not honor attr_protected/accessible when used with a hash ( closes #11422 ) [miloops]
...
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@9090 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2008-03-25 23:56:48 +00:00
David Heinemeier Hansson
c6f2af5c31
Added ActiveRecord#Base.all/first/last as aliases for find(:all/:first/:last) ( closes #11413 ) [nkallen, thechrisoshow]
...
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@9085 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2008-03-24 19:59:22 +00:00
Rick Olson
081ddb6f24
Merge the has_finder gem, renamed as 'named_scope'. Closes #11404 [nkallen]
...
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@9084 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2008-03-24 02:50:02 +00:00