Commit Graph

10802 Commits

Author SHA1 Message Date
Emilio Tagua
c57f94d730 Merge commit 'rails/master' 2009-08-21 17:43:32 -03:00
taryn
ce61a6bd55 Added first/last/all aliases for equivalent find scopes
Just a copy from Active Record (with tests). Each is a warpper function for
the equivalent scoped call to find eg first is a wrapper for find(:first)

Signed-off-by: Joshua Peek <josh@joshpeek.com>
2009-08-21 14:49:59 -05:00
Jeremy Kemper
8bc3a14727 Benchmark script via miloops' arel fork via DataMapper's AR comparison script 2009-08-20 21:09:59 -07:00
Emilio Tagua
0c6aed0a09 Add bench script for ActiveRecord. Ignore log file and temporary cache
sql files.
2009-08-20 18:58:12 -03:00
Emilio Tagua
a60334fdc5 Remove useless conditionals/local var. 2009-08-19 19:36:06 -03:00
Emilio Tagua
54fcbb881d Make sure join association methods are called once. 2009-08-19 17:45:13 -03:00
Emilio Tagua
b32474020c Don't sanitize_sql where it doesn't make sense. 2009-08-19 16:29:26 -03:00
Emilio Tagua
ccf5f2c4a2 Remove old method and comment. 2009-08-19 16:17:16 -03:00
Emilio Tagua
3e1ef198e0 Remove useless InnerJoinDependency, inner joins are performed through
Arel::InnerJoin.
2009-08-19 16:08:54 -03:00
Emilio Tagua
b342728677 Merge commit 'rails/master' 2009-08-19 11:09:24 -03:00
Emilio Tagua
2048556a14 Remove whitespace. 2009-08-19 11:09:12 -03:00
taryn
328ba3b333 Added save! which raises ResourceInvalid unless valid?
Similar to Active Record - it will raise ActiveResouce::ResourceInvalid if
the resource is not valid (ie if <tt>valid?</tt> returns false)

However - does not raise ActiveResource::ResourceNotFound if the callbacks
fail (callbacks have not yet been implemented) - it will just try to save
and raise if the callbacks all fail.

This is not ideal behaviour - but will do until we decide to change the
behaviour of save_with_validations to actually raise (rather than catch) the
ResourceInvalid exception.

Signed-off-by: Joshua Peek <josh@joshpeek.com>
2009-08-19 09:05:02 -05:00
taryn
4dc05bc8a9 Swallow ResourceNotFound error on find_every
Active Record does not explode with RecordNotFound if you go looking for a
collection of objects - it just returns nil. Thus Active Resource should
also not explode.

After all - finding no objects that match a set of conditions is not
exceptional behaviour - unlike looking for a specific object with a given id
(which you'd expect to exist).

I've also added documentation to +find+ to reflect this.

Signed-off-by: Joshua Peek <josh@joshpeek.com>
2009-08-19 09:04:48 -05:00
taryn
079ed8fc43 Pulled find-based tests into their own test case. This matches Active Record, and allows us to have one places where all find-tests are located, which will help when adding dynamic finders later.
Signed-off-by: Joshua Peek <josh@joshpeek.com>
2009-08-19 09:04:14 -05:00
taryn
36bf587347 Moved all test cases into a new test/cases directory to match Active Record test directory structure.
Signed-off-by: Joshua Peek <josh@joshpeek.com>
2009-08-19 09:03:57 -05:00
taryn
c2f90d6530 Added validations to ActiveResource. Added a smoke test to see if we can add a validation and use it, and add a validates callback and use it.
Signed-off-by: Joshua Peek <josh@joshpeek.com>
2009-08-19 09:03:17 -05:00
Emilio Tagua
c36cfa7568 Remove unused quoted_record_ids, now ARel does this using ARel::In. 2009-08-18 20:03:32 -03:00
Emilio Tagua
a09215ee96 has_many nullify associations keys using ARel. 2009-08-18 20:02:14 -03:00
Emilio Tagua
a7178773d2 Remove now unused quote_table_name, ARel does that quoting now. 2009-08-18 19:53:21 -03:00
Emilio Tagua
d5476b466f habtm insertion with ARel integration. 2009-08-18 19:51:41 -03:00
Emilio Tagua
c1f833dff4 habtm delete method integrated with ARel. 2009-08-18 19:38:34 -03:00
Emilio Tagua
0abba2813b Call to_sql method on ActiveRecord::Relation instance not it's relation
attribute.'
2009-08-18 19:38:03 -03:00
Emilio Tagua
74ed123e08 Override respond_to? in ActiveRecord::Relation to go with
method_missing.
2009-08-18 16:35:33 -03:00
Emilio Tagua
fefb4c78ac Cache arel_table when possible, use class method arel_table instead
instance method.
2009-08-18 16:28:04 -03:00
Emilio Tagua
0d6997b6e3 Cache #arel_able when possible. 2009-08-18 14:49:11 -03:00
Emilio Tagua
60926db9e0 Inline initializer setup. 2009-08-18 14:22:38 -03:00
Emilio Tagua
66fbcc1de6 Use immutable relation objects to generate queries. 2009-08-18 14:10:03 -03:00
Mike Gunderloy
ef93524058 Remove sqlite2 build from CI recipe [#3066 state:resolved]
Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
2009-08-18 13:24:39 +01:00
Emilio Tagua
ac03bc91db Use explicit method definition instead of metaprogramming. 2009-08-18 08:27:37 -03:00
Emilio Tagua
fa8f5c2667 Relation#joins! should know what to join instead of delegating to
construct_join.
2009-08-18 08:18:24 -03:00
Emilio Tagua
08f6af2d53 Fix typo in test classname. 2009-08-18 08:12:35 -03:00
Emilio Tagua
79e951ca9b Use finder options as relation method names to provide more familiar
naming. Use bang methods convention in methods that alter the
relation.
2009-08-18 07:50:11 -03:00
Emilio Tagua
c923409630 Clean up relation joins when finding records with included associations. 2009-08-17 20:17:40 -03:00
Emilio Tagua
4b339f44bd Merge commit 'rails/master' 2009-08-17 19:46:32 -03:00
Emilio Tagua
c01c8967a0 Merge commit 'rails/master'
Conflicts:
	activerecord/lib/active_record/calculations.rb
2009-08-17 19:46:06 -03:00
Pratik Naik
25e5b0c4a8 Remove support for SQLite 2.
If you're still using it, please install the plugin from git://github.com/rails/sqlite2_adapter.git
2009-08-17 14:54:34 +01:00
Joshua Peek
ff1b0d3c86 k, thats really slow, lets not 2009-08-16 21:21:39 -05:00
Joshua Peek
24ad9ae3d2 Cleanup route reloading in tests. Prefer with_routing over using ActionController::Routing::Routes directly 2009-08-16 21:14:26 -05:00
Emilio Tagua
770fca10fb Remove group when building the relation, it will be added later if
options[:group] is given.
2009-08-16 17:27:45 -03:00
Yehuda Katz
ccf28d2499 Fixes ActionMailer regression [#3059 state:resolved] 2009-08-15 20:38:50 -07:00
Yehuda Katz
d6d550f0cb Missing fixture template -- fixes AP tests 2009-08-15 20:33:34 -07:00
Jay Pignata
7213da37ce Fix test_has_many_through_polymorphic_has_one on sqlite2 [#3054 state:resolved]
Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
2009-08-15 19:14:32 -07:00
Jay Pignata
cb3e669b0d Fix calculation tests on sqlite2 [#3053 state:resolved]
Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
2009-08-15 19:14:11 -07:00
Jeremy Kemper
76335c27b6 Bump pg gem requirement to 0.8.0. Build psql db with UTF8 encoding. 2009-08-15 19:04:25 -07:00
Jay Pignata
679128da58 Adding a call to logger from params_parser to give detailed debug information when invalid xml or json is posted
[#2481 state:committed]

Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
2009-08-15 16:51:03 -07:00
Joshua Peek
911acc10de Axe "best fit" generation support 2009-08-15 18:08:46 -05:00
Jeremy Kemper
df6617bc8a Normalize route generation order: associations, yield block, then own routes. 2009-08-15 15:56:52 -07:00
Yehuda Katz
1310231c15 Got tests to pass with some more changes.
* request.formats is much simpler now
    * For XHRs or Accept headers with a single item, we use the Accept header
    * For other requests, we use params[:format] or fallback to HTML
    * This is primarily to work around the fact that browsers provide completely
      broken Accept headers, so we have to whitelist the few cases we can
      specifically isolate and treat other requests as coming from the browser
    * For APIs, we can support single-item Accept headers, which disambiguates
      from the browsers
  * Requests to an action that only has an XML template from the browser will
    no longer find the template. This worked previously because most browsers
    provide a catch-all */*, but this was mostly accidental behavior. If you
    want to serve XML, either use the :xml format in links, or explicitly
    specify the XML template: render "template.xml".
2009-08-15 12:32:02 -07:00
Yehuda Katz
9b552fb300 Caches and cache clearing seems to actually work, but the actual architecture is kind of messy. Next: CLEAN UP. 2009-08-15 12:32:01 -07:00
Yehuda Katz
9f5cd0156a More cleanup of ActionView and reduction in need for blocks in some cases:
* only one of partial_name or :as will be available as a local
  * `object` is removed
  * Simplify _layout_for in most cases.
    * Remove <% render :partial do |args| %>
    * <% render :partial do %> still works fine
2009-08-15 12:32:01 -07:00