On 8/20/07, Courtenay <[EMAIL PROTECTED]> wrote:
>
> Hi guys, what do you think about this implementation (before I go off
> and actually make it work).  The plan is to make it easier to write
> extensions or plugins for find, as well as define your own options for
> the precious first-level argument, :first, :all, etc.

There's definitely some scope for tidying up some of those ....
interesting bits of Base which generate the queries.

> This will also allow some fun things, like, keeping state in the
> finder, or even recording the last SQL statistics.
>
>   @user = User.find(2)
>   User::Finder.records_returned => 25
>   User::Finder.benchmark => 0.025
>
> What do you guys think? All the AR tests still pass with this method,
> since it's a fairly simple proxy, but it allows for much greater
> customization.

What kind of customisation did you have in mind?

I've been kicking around a few more changes to AR::Base lately and
perhaps we could do something along these lines. My thoughts on our
querying at present are:

* It should be in / near the adapters.

There's already some code that needs to be different but is currently
implemented in base, by checking what the adapters support:

      # Should primary key values be selected from their corresponding
      # sequence before the insert statement?  If true, next_sequence_value
      # is called before each insert to set the record's primary key.
      # This is false for all adapters but Firebird.
      def prefetch_primary_key?(table_name = nil)
        false
      end

That could ideally simply be handled with polymorphism

* It should be easier to inject conditions into the generated queries.

Basically the only reason that people are currently using with_scope
is to merge :conditions arguments.  It should be easier to define
scopes, inject conditions into queries etc.   This probably means some
kind of query class.

Combining these two would also aid databases like oracle which get
serious performance gains from the use of prepared statements.


-- 
Cheers

Koz

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-core?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to