From: Colin Putney Date: 2002-05-20T08:25:46+09:00 Subject: Re: Object <-> Relational mapping Avi Bryant wrote come interesting code for this. http://beta4.com/kansas.tgz It works the opposite way to many OR mapping systems - by analysing the database and generating classes that map to the various tables. It also takes care of generating the SQL, and lets you do queries in straight ruby. For example, let's say I have a Sales database with a table called Customer: db = Sales.new smiths = db.select(Sales::Customer) {|c| c.cust_id < 100} smiths.each { |c| puts c.name } I don't think it's ready for production use, but it's an interesting approach and may be a good starting point for you. At the very least it's food for thought. Colin On Sunday, May 19, 2002, at 09:51 AM, Thomas Hurst wrote: > I'm getting very, very tired of writing code that looks like this: > > db.select_all(long_sql_statement) do |row| > foo = Foo.new > foo.a = row['a'] > foo.b = row['b'].to_i > foo.c = row['c'].to_f > #... > foo.z = row['z'] > end > > It gets even worse when you get relations etc to worry about. > > I've heard of at least two mentions of people writing object-relational > mappers, and I'm sure plenty of you lot have written db heavy apps. > > Suggestions? :) > > -- > Thomas 'Freaky' Hurst - freaky@aagh.net - http://www.aagh.net/ > - > Familiarity breeds attempt. >