On Oct 20, 2009, at 8:01 PM, Nate Wiger wrote:
> One follow-up: Is there any reason why this is not supported?
>
>   game.game_players_dataset[17]
>
> There's an explicit error thrown, and an explicit check in the class
> for this situation:
>
>    # Returns the first record matching the conditions. Examples:
>    #
>    #   ds[:id=>1] => {:id=1}
>    def [](*conditions)
>      raise(Error, ARRAY_ACCESS_ERROR_MSG) if (conditions.length == 1
> and conditions.first.is_a?(Integer)) or conditions.length == 0
>      first(*conditions)
>    end
>
> Which is odd to me only because these work and are supported:
>
>    Game[4]
>    GamePlayer[17]

Making a guess:

Model.[] allows a single integer because there is a one-to-one  
correspondence with a DB table and the primary key or keys are known.

A dataset may represent a join or other composition of multiple  
tables, or a subset of columns from a single table (possibly without  
any primary key column(s)). Thus, Dataset#[] can't reliably know  
anything about the primary key column(s) that may or may not be present.

Am I right?

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sequel-talk" 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/sequel-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to