Questions tagged [sqlboiler]
23 questions
5
votes
3 answers
SQLboiler not in clause
I am trying to follow the examples in sqlboiler (https://github.com/volatiletech/sqlboiler). But, I can't find a way to get equivalent of NOT IN query.
users, err := models.Users(
Select("id", "name"),
Where("age > ?", 30),
AndIn("c.kind in…

Coder
- 1,415
- 2
- 23
- 49
2
votes
0 answers
Generate `CREATE TABLE...` statement from an sqlboiler model
Is it possible to generate a create statement (CREATE TABLE...) from a built SQLBoiler model?
// Node is an object representing the database table.
type Node struct {
ID int64 `boil:"id" json:"id" toml:"id" yaml:"id"`
Address…

BigP
- 117
- 7
2
votes
0 answers
How to use returning clause on update/upsert
I wish to know how I can use postgres returning clause with SQL Boiler elegantly.
For example I wish to update some object by some fields and return the object id:
err = queries.RawG(`update users
set name='test-name'
…

Or Yaacov
- 3,597
- 5
- 25
- 49
2
votes
0 answers
How to mock sqlboiler queries in Go
Here I have been trying to find out to mock the sqlboiler(an ORM generator) queries but could not find the way.
Can anyone work around mocking the sqlboiler queries?
Example:
func (m *Message) updateDevice(parentID int, data map[string]interface{})…

Siyaram Malav
- 4,414
- 2
- 31
- 31
2
votes
0 answers
How to perform a many-to-many query with SQLBoiler
I'm using SQLBoiler as my golang ORM.
I'm trying to query a user and all of his roles, to do that I have the following tables:
ROLES:
role_id desc name
1 basic basic
USERS:
user_id password user_name created_at updated_at …

Or Yaacov
- 3,597
- 5
- 25
- 49
1
vote
1 answer
not able to generate generated_sort.go from gqlgen-sqlboiler
I am using
sqlboiler version: v4.14.2
gqlgen version: v0.17.33
gqlgen-sqlboiler version : v3.3.12
https://github.com/web-ridge/gqlgen-sqlboiler
After following readme.md pre requisite getting following error while running convert.go
following is…

Rupesh Terase
- 440
- 3
- 14
1
vote
0 answers
sqlboiler doesn't show any queries after debug mode
I wrote boil.DebugMode = true, just after the db connection setting is.
However, when I write some select query by sqlboiler syntax, sqlboiler doesn't show any queries after debug mode.
Are there any reason I cant't see any queries in command line?

Jack
- 125
- 1
- 1
- 10
1
vote
1 answer
Sqlboiler doesn't work with variable originated from c.Query in gin framework
I want to use sqlboiler with a variable which come from c.Query() in gin framework, but sqlboiler returns ERROR: sql: no rows in result set. Are there any ways to pass the variable?
Here is my sample code:
func getUser(c *gin.Context){
name :=…

Jack
- 125
- 1
- 1
- 10
1
vote
2 answers
SQLBoiler Eager Loading: how to load specific row?
I want to execute this eager loading query by SQLBoiler in order to get specific row.
SELECT * FROM `room_users` WHERE (`room_users`.`room_id` IN (?,?,?,?) AND (room_users.user_id=?, 2));
But, I don't know how to write query in SQLBoiler.
My code…

kkkkgyg
- 69
- 8
1
vote
2 answers
One to many inserting
I have two models: Order and OrderItem. I need to insert order and item of it from same request, e.g.:
{
"user_id": "1",
"total_price": "200",
"items": [
{
"product_id": 1,
"quantity": 10
},
…

loc.dang
- 374
- 3
- 19
1
vote
0 answers
Unit Testing sqlboiler with sqlmock failing select
I'm trying to mock a method written with sqlboiler but I'm having massive trouble building the mock-query.
The model I'm trying to mock looks like this:
type Course struct {
ID int, Name string, Description null.String, EnrollKey string, ForumID…

Karparetzu
- 11
- 3
1
vote
0 answers
Context deadline exceeded when working with Plaid HTTP API
This is one of my API functions; if I call this function continuously. The api showing loading only. Not getting any response.. then I got 502 error with log
error serving {"error": "context deadline exceeded", "errorVerbose": "context deadline…

Mia Mia
- 143
- 12
1
vote
0 answers
Go lang Using SQL Boiler with Limit, Offset
I am using SQL boiler and GOlang
"github.com/volatiletech/sqlboiler/v4/queries"
"github.com/volatiletech/sqlboiler/v4/queries/qm"
I want to set limit, offset and orderby in different columns
my code is
queryMods := []qm.QueryMod{
…

Mia Mia
- 143
- 12
1
vote
1 answer
Golang SQLBoiler returns nothing when running orderby
I'm using SqlBoiler on Go to send requests to a PostgreSQL db, but when trying to order the database by one of the fields it returns 0 rows.
At first i run a count (like detailed below) and if the count returns more than or equal to one row then i…

Riverans
- 336
- 1
- 12
1
vote
0 answers
Why null string values do not work on UPDATE?
I'm using sqlboiler to generated Go models from SQL and I've came across the following problem. When specifying ON CONFLICT via sqlboiler code:
dev := models.Device{
ID: deviceID,
Type: null.StringFrom("device"),
// Name: …

Patryk
- 22,602
- 44
- 128
- 244