News for hackers. Stuff that matters.
Re:To ORM or Not to ORM by y4mi on Tuesday May 07, 2019 @01:36PM (#19851621)
I love orms.

They make a simple crud operation so easy, you don't even have to think about them.

Every remotely competent developer will however tell you that there are always cases where the orm is a bad fit. And that's exactly why basically all orms let you write your own queries.

There is really no reason not to use an orm. Just don't ever frown on people doing anything more advanced than a middle join without it.

Re:To ORM or Not to ORM by megous on Tuesday May 07, 2019 @02:27PM (#19852100)
You don't need ORM for simple CRUD operations. All you need is a function you can pass a table name and a map of column names/values you want to insert/update.
Re:To ORM or Not to ORM by dpcx on Tuesday May 07, 2019 @02:33PM (#19852165)
Until you want to be able to sort and filter and do all of the other things that most CRUD applications do.

Once you're there, if you're doing SQL directly, now you're manipulating strings in your code, instead of being able to build some kind of object that then generates a query for you.

Re:To ORM or Not to ORM by macNchz on Tuesday May 07, 2019 @02:42PM (#19852233)
Yeah if you’re doing lots of CRUD that approach quickly becomes an exercise in writing your own (bad, buggy) ORM.
Re:To ORM or Not to ORM by megous on Tuesday May 07, 2019 @06:32PM (#19854048)
Not at all. The only cumbersome thing about SQL, that is common enough and unpleasant to always spell out by hand are basic INSERT and UPDATE commands.

I use a set of 3-4 functions that I reuse pretty much in all my programs for this. It's no ORM, as it doesn't map classes to tables/data in the database. It's just a shortcut to generate and execute INSERT/UPDATE commands on arbitrary tables with arbitrary columns.

Also it has zero bugs, because you can hardly create bugs in something so simple.

Re:To ORM or Not to ORM by throwawaycorn on Tuesday May 07, 2019 @09:56PM (#19855264)
> you can hardly create bugs in something so simple.

You may have underestimated how bad things are in some of the unicorns..

1. Creating your own query builder before understanding the purpose of bind param: https://medium.com/tokopedia-engineering/dynamic-sql-query-b...

2. ???

3. Profit from SQL injection: https://www.youtube.com/watch?v=PKkNjOweWTE

Re:To ORM or Not to ORM by stefanfisk on Tuesday May 07, 2019 @02:41PM (#19852218)
It sounds like you are conflating an ORMs with query builders?
Re:To ORM or Not to ORM by dpcx on Tuesday May 07, 2019 @02:48PM (#19852270)
Query builders and ORMs often go hand in hand in my experience, as the ORM will expose the ability to perform custom querying capabilities around the specific object you're working with; however, you're correct in that I am more considering query builders than ORMs directly in this instance.