Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Non-retarded ORMs, and a general ORM discussions.

by Joost (Canon)
on Jun 16, 2006 at 22:57 UTC ( [id://555905]=note: print w/replies, xml ) Need Help??


in reply to Non-retarded ORMs, and a general ORM discussions.

The purpose of my investigation was to incorporate an ORM into an MVC. I like what rails did mutating the both of them into one. But, I think they choose the worst ORM to do so. I don't like the fact that I'm supposed to design in an app, and roll changes to a db.

First off, Rails doesn't mutate the ORM into an MVC - rails just makes it easy to generate a Model View and Controller classes based on a database table. You don't have to generate each, and in my view the Model classgeneration is probably the most useful.

Secondly, If you don't change the DB, you're free to change the (possibly generated) classes as you see fit, but if you do change a DB table's fields, the model changes automatically with it (via ActiveRecord).

Maybe I'm misinterpreting that part of your post, but I don't really see what you mean there.

  • Comment on Re: Non-retarded ORMs, and a general ORM discussions.

Replies are listed 'Best First'.
Re^2: Non-retarded ORMs, and a general ORM discussions.
by EvanCarroll (Chaplain) on Jun 19, 2006 at 06:05 UTC
    Rails makes the ORM an intergal part of the framework. The ORM sucks; hence, by proxy, the framework sucks. That is what I mean.
    First off, Rails doesn't mutate the ORM into an MVC - rails just makes it easy to generate a Model View and Controller classes based on a database table.
    If the egg comes before the chicken it is anything but "easy." Rails doesn't generate a model, it generates a file for you to statically type the model. Now, before I started this rant, I was unaware of Alzabo, DBIx::Class's Schema::Loader, or Rose::DB, I'm currently setting up Rose::DB and liking it a lot. - And thanks to the monks with info - These frameworks do what you mentioned, "generate a model ... based on a database table." Rails simply adds getter/setter methods for the table. Big deal. In the rails community they teach DRY like it is a religion, and then they make the assumption that every DB lacks constriants, and that every programmer wishes to treat the DB as if it had the feature set of SQL lite, or MySQL 3.2. Every programmer doesn't -- I don't. Furthermore, rails doesn't generate a a Model, View, or Controller based on a database table, it generates them based on the arguement you give to the generator, wheither or not they exist is your problem. (though again, like most ORMs it can transparently add the getter/setters for the instances at run time)
    Secondly, If you don't change the DB, you're free to change the (possibly generated) classes as you see fit, but if you do change a DB table's fields, the model changes automatically with it (via ActiveRecord).
    You're obviously misguided. ActiveRecord does not change the model to reflect changes in the db, ever. The only thing the model automatically does, is generate </quote> Alright then, change the primary key, change a check constraint, change a foreign key, change a data type. Oh, look, ActiveRecord proves how adaptive it is yet again. In AR if you create a table with an int column, you can rightfully, or wrongfully attempt to insert a string. The following comes from a ruby bot I was writing with a rails interface, my second rails project. Observe:

    channel.population = 'foo' channel.save
    Yields this: UPDATE channel SET "name" = '#debian-uy', "descr" = 'Debian Uruguay | http://debianuruguay.org | Si quieres pegar código: http://debian-uy.pastebin.com/ | Gran Campaña Pro-Mirror: http://debianuruguay.org/node/129', "population" = 0 WHERE pkid = 3

    Thats right, I inserted into an int, the value 'foo', and rails converted that to a numeric 0. I once again, did not tell rails to update name, descr, or pkid. I told it to update population and it generated this statement. What a waste, without a .save(), it won't flush the instance, and with a .save() it flushes the object dispite the content, how primitive.


    Ruby syntax is clean, it is a fun language, and I look forward to a more advanced framework that is flexible and reflects the richness and cleanliness of Ruby's grammer. Rails isn't it.


    Evan Carroll
    www.EvanCarroll.com

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://555905]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (4)
As of 2024-04-23 22:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found