Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

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

by EvanCarroll (Chaplain)
on Jun 19, 2006 at 06:05 UTC ( [id://556190]=note: print w/replies, xml ) Need Help??


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

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://556190]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (6)
As of 2024-04-23 13:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found