The piece you are missing about ORM is the automatic change detection and 
caching when using complex object graphs. This is not trivial by any means when 
using raw SQL. It’s not easy using an orm either sometimes - depends on the 
orm. 

> On Sep 27, 2019, at 6:13 AM, Dimas Prawira <prawira.dimas.yu...@gmail.com> 
> wrote:
> 
> if there's something you _don't_ know how to do in SQL, and it seems the ORM 
> can do it for you, capture the raw SQL the ORM produces
> and tell me if it's easier for you to understand the SQL or the random ORM 
> API. I 100% guarantee you that the raw SQL the ORM produces will be easier to 
> understand
> 
> ie: you could write the same raw SQL too, if you just tried
> 
> 
> All i'm suggesting is: try to learn raw SQL — i think you'll be pleasantly 
> surprised at just how flexible and easy it is
> i would also argue that learning SQL is easier than learning a random ORM 
> syntax. and raw SQL has the benefit that you'll be able to use it again, on a 
> future project, in a different programming language
> while every ORM i've ever seen is 100% bound entirely to only the programming 
> language it's used in
> i've never seen two ORMs with the same API, or even a similar API
> but raw SQL stays the same, for now and 50+ years from now
> 
> 
> Let me give you an example :
> 
> // newSession creates a new session in the database, returning the created    
>   // session id.    
>   func (s *server) newSession(remoteAddr string) (int64, error) {    
>       const sqlstr = `insert into sessions (remote_addr) values ($1) 
> returning session_id`    
>       var id int64    
>       if err := s.db.QueryRow(sqlstr, cleanRemoteAddr(remoteAddr)).Scan(&id); 
> err != nil {    
>           return 0, err    
>       }    
>       return id, nil    
>   }
> 
> queries are just as simple.
> -- 
> You received this message because you are subscribed to the Google Groups 
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to golang-nuts+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/golang-nuts/CA%2Bp%2BMUebx-LZ%2Bj9qTvoDJrL7RCyBrNJ5P6nq0M8YPs3wh_HCEQ%40mail.gmail.com.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/1DCC8F36-9213-42E7-A156-273A93429686%40ix.netcom.com.

Reply via email to