3 ms·
I’m super biased but I still hate them. There’s something powerful and simple being able to execute parametered queries. Alas if the industry is going this way
by gigatexal 8y ago
I’m super biased but I still hate them. There’s something powerful and simple being able to execute parametered queries. Alas if the industry is going this way then I’ll have to adapt.
- pmontra 8y agoParametered queries == prepared statements? Rails' ActiveRecord creates prepared statements and even caches query results by default. It's pretty useful to write stuff like Book.where(genre: 'scifi').count or Author.where(name: 'Frank Herbert').books.order_by(:publishing_date).first.title. You get the result immediately. Of course title = sql(select title from books ... ) would be quite ok too ( * ), but it turns out that some simple queries are quite long to write. I tend to use SQL only when I have to start looking at the documentation of the ORM. ( * ) I know no tool that can write queries like that but it would be great.
- gigatexal 8y agoSee that conciseness I don’t see as a benefit. I do acknowledge the downside of having a query in a method and maybe having to tweak the same type of query in a handful of methods any time the schema changes. It’s a good way to introduce bugs I guess. At that point I would just use stored procedures.