On Aug 30, 6:57 pm, oldmoe <[EMAIL PROTECTED]> wrote:
> I am still wondering why DO needs to rewrite every
> driver from scratch?
> If they see shortcomings in the current ones, why don't they just
> contribute their fixes
> so every one benefits?

We don't rewrite the drivers. We've written a Ruby/C wrapper on top of
the drivers. It's really a trivial effort for a C professional.

The other half of DO is dedicated to type-casting on the C side before
objects are pushed across into Ruby. Purely as a performance
optimization. So instead of DataMapper saying "this String should be
an Integer" when assigning to a local-variable of a model instance, it
can tell the DO driver ahead of time that it wants a particular column
as an Integer, so it does much less work.

connection = DataObjects::Connection.new("sqlite3://#{Dir.pwd}/
test.db")
command = connection.create_command("SELECT id, name, active FROM
users WHERE id = ?")

# This is the important line!
command.set_types([Integer, String, TrueClass])

reader = command.execute_reader(123)

while(reader.next!) do
  puts reader.values
end

reader.close
connection.close

The above example code works for Sqlite3, MySQL and Postgres. The only
thing you have to change is the connection's URI.

And that's the real goal of DO. Java has JDBC, .NET has ADO.NET and
now Ruby has DO. The first unified database driver API for Ruby in
it's history.

/warning: soapbox=on/
I'm actually a bit disappointed that more Rubyists don't recognize the
significance of this and continue on writing slightly different
database interactions for the standard differing drivers. In my mind
the disparate standard drivers just need to die. The sooner the
better.

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

Reply via email to