Vasiliy, Take a look at the supported examples. sqlc has no problem handling five joins and a having clause.
Kyle On Wednesday, December 11, 2019 at 12:18:20 PM UTC-8, Vasiliy Tolstov wrote: > > Thanks! But how about real world cases like joining 5 tables and using > having and other stuff? > > ср, 11 дек. 2019 г. в 22:48, <ky...@conroy.org <javascript:>>: > > > > Hey gophers, > > > > I'm excited to announce sqlc, my project for turning SQL into type-safe > Go. With sqlc, the following SQL: > > > > > > CREATE TABLE authors ( > > id BIGSERIAL PRIMARY KEY, > > name text NOT NULL, bio text > > ); > > > > > > -- name: GetAuthor :one > > SELECT * FROM authors WHERE id = $1 LIMIT 1; > > > > gets turned into this Go > > > > package db > > > > import ( > > "context" > > "database/sql" > > ) > > > > type Author struct { > > ID int64 > > Name string > > Bio sql.NullString > > } > > > > const getAuthor = `-- name: GetAuthor :one > > SELECT id, name, bio FROM authors > > WHERE id = $1 LIMIT 1 > > ` > > > > type Queries struct { > > db *sql.DB > > } > > > > func (q *Queries) GetAuthor(ctx context.Context, id int64) (Author, > error) { > > row := q.db.QueryRowContext(ctx, getAuthor, id) > > var i Author > > err := row.Scan(&i.ID, &i.Name, &i.Bio) > > return i, err > > } > > > > I wrote up a larger piece about why I started the project here: > https://conroy.org/introducing-sqlc. It includes a guided walk through > and more example code. > > > > Happy to answer any questions you have about the project. > > > > Cheers, > > Kyle > > > > -- > > 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 golan...@googlegroups.com <javascript:>. > > To view this discussion on the web visit > https://groups.google.com/d/msgid/golang-nuts/2d87986d-fc00-4fc2-afa3-352dedc2f9b7%40googlegroups.com. > > > > > > -- > Vasiliy Tolstov, > e-mail: v.to...@selfip.ru <javascript:> > -- 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/07e8f1b2-0576-4f8a-ab78-864759b71af2%40googlegroups.com.