Questions tagged [sqlc]

sqlc generates type-safe idiomatic Go code from SQL. Here's how it works:

  • You write queries in SQL
  • You run sqlc to generate code with type-safe interfaces to those queries
  • You write application code that calls the generated code
43 questions
1
vote
2 answers

the PostgreSQL engine does not support Windows

I try to generate golang code using sqlc package but it say "the PostgreSQL engine does not support Windows" I tried to generate code for insert operation in postgresql for which I used postgresql alpine docker image. my sql.yaml file is version:…
Pramod
  • 21
  • 6
1
vote
0 answers

GoLang | SQLC | How to log SQL queries when invoked using fmt

How to log SQLC queries with the values passed to the receiver functions? What I'm thinking is to get the constant variable of the query and format it using a function. Is there any easier way or SQLC feature for this? Thank you!
M.K.
  • 23
  • 1
  • 3
1
vote
1 answer

How to make an update query using join?

I'm trying to write an update query for 2 tables, but I'm facing an error, can you help? I'm using postgresql I'm using sqlc with golang. UPDATE categories SET c.slug = $1, tx.name = $2, tx.description = $3 FROM categories c JOIN…
Developer
  • 21
  • 3
1
vote
0 answers

inserting json to db

I use https://github.com/kyleconroy/sqlc This is a library for generating code. My query -- name: SetAssignmentsResult :exec UPDATE assignments SET status = 'ACCEPTED', result = $1 WHERE task_id = $2 AND item_id = $3 AND marker_id =…
Nakem1
  • 313
  • 1
  • 10
1
vote
1 answer

Return values consisting of the set in Posgresql

I use https://github.com/kyleconroy/sqlc to generate code. I want to return human_id using the group_id array. -- name: HumansByGroupID :many SELECT human_id FROM groups WHERE group_id IN (UNNEST($1::uuid[])); return ERROR: set-returning functions…
Nakem1
  • 313
  • 1
  • 10
0
votes
0 answers

Postgres SQL - get column name as variable

I am trying to have a query that will be something like this: SELECT * FROM some_table WHERE $1 = $2 I am using sqlc to generate everything needed to execute the query so I don't have the option the use a formatted string. I was also trying to do…
0
votes
1 answer

I got error SQLC generate with join, array

I am developing an API server with postgreSQL, golang, sqlc. My sql is as follows SELECT e.*, rslt.artineve FROM events AS e, LATERAL ( SELECT ARRAY (SELECT art_id FROM arteve WHERE arteve.eve_id = e.uid) AS artineve ) rslt; And sqlc generate…
MoonTaeTae
  • 51
  • 6
0
votes
1 answer

Golang SQLC not generating structs

I am using sqlc and mysql, for some reason the generated code that is meant to execute the queries doesn't have the structs or fields in the functions for the objects am supposed to insert or query the db with. My create table query looks similar to…
Tosh
  • 93
  • 10
0
votes
1 answer

SQLC named parameter in generated code for sql containing conditional where

I am using golang SQLC to generate CRUD operation go code from sql. My select query is like bellow -- name: SearchProducts :many SELECT * FROM product WHERE ( $1::varchar(100) IS NULL OR name LIKE '%$1%' ) AND ( $2::varchar(1000) IS NULL OR…
Anup
  • 1,502
  • 2
  • 15
  • 31
0
votes
1 answer

How to shrink this code and merge the if and else condition

if category == 0 { rows, err := h.Repo.GetAllLatestProducts(c.Context()) if err != nil { return c.Status(fiber.StatusInternalServerError).SendString(err.Error()) } result := make([]interface{},…
Priyank Bolia
  • 14,077
  • 14
  • 61
  • 82
-1
votes
1 answer

Invalid Memory Address or Nil Pointer Deference Issue in Gin-Gonic

Revised Question I am trying to create a new user using Golang. I have a CreateUser() function in my UserImplementation struct which takes a pointer to a User model. The function is responsible for creating a new user record in the database.…
-1
votes
1 answer

How to handle incompatible concrete return types between an interface and types that implement it in golang?

I am still learning Go and I decided to use Domain Driven Design with interfaces. I want to support mysql, postgresql and sqlite by choosing the engine at run time depending on the execution environment. Since all the db actions are the same…
keystroke33
  • 159
  • 3
  • 11
-2
votes
1 answer

Issue with Sqlc auto generated code golang

/ Code generated by sqlc. DO NOT EDIT. package db import ( "context" "database/sql" ) type DBTX interface { ExecContext(context.Context, string, ...interface{}) (sql.Result, error) PrepareContext(context.Context, string) (*sql.Stmt,…
1 2
3