Questions tagged [go-gorm]
GORM is an ORM library for the programming language Go, developed by jinzhu.
go-gorm
1,968
questions
1
vote
0
answers
19
views
Why GORM automigrate will try to drop a non-exist index
I have a type as
type Customer struct {
gorm.Model
CorpId string `gorm:"column:corpid"`
Name string `gorm:"column:Name"`
Age int
}
And I use GORM to do the ...
2
votes
0
answers
46
views
GORM adding "AND column.id = 1", why?
Im having an issue with GORM on my GIN project.
Please help me if possible.
My issue is:
var class models.Classrom
var old_class models.Classrom
old_class.ClassID = "algorithm"
DB.Model(&...
-3
votes
1
answer
39
views
Golang model json return empty on join tables [closed]
Please help me to explain why this code fail, why on json result trip_from has empty string :
type Trip struct {
ID int `json:"id" gorm:"primary_key"`
Name string ...
1
vote
1
answer
26
views
How to config query timeout default for all query?
I am working with GORM in my Go application and I need to set a default query timeout for all queries. Currently, I have individual queries where I set the timeout explicitly, But I want to avoid ...
0
votes
0
answers
7
views
Workbench not opening on the Desktop
I have installed Mysql on my system using the normal documentation procedures and instructions. I have also downloaded the Mysql workbench also by following instruction from Msql documentation website....
0
votes
0
answers
27
views
How to Write Unit Tests for GORM Repository Method with gomock?
I am trying to write unit tests for a GORM repository method using gomock to mock database interactions. However, I'm running into issues with nil pointer dereference errors. Below are the relevant ...
0
votes
1
answer
55
views
How to create a generic array in GO?
I have a function that needs to receive a GORM model as a parameter, and depending on the model I receive as a parameter, I need to create an Array(Slice) based on the type of the struct(gorm model) I ...
1
vote
1
answer
49
views
GORM Help w/ Postgres: unsupported data type [closed]
I'm trying to read through the CVE List to put all the entries into a central database. When I try to create an entry to this databse, I get an error: 2024/07/02 14:03:13 /x/db.go:68 unsupported data
...
-1
votes
1
answer
45
views
Cannot use exported method that belongs to the package in Golang
I've got a package named services. This is the structure of the package:
services/
third_party/
discogs.go
discogsAPIStructs.go
artist_srv.go
auth_srv.go
record_srv.go
...
-4
votes
1
answer
33
views
How to use subquery into field on gorm query
I have a query like this:
select a.id,
(
select max(b.last_update_login)
from login_history b
where b.user_id = a.id
) last_update_login
from user a
How do I convert this into a ...
1
vote
0
answers
35
views
Golang GORM Recursive Structure Migration (MySQL)
I'm trying to create a recursive table structure, but I have not had any luck. Here's a simple example of what I'm trying to achieve:
package models
import (
"gorm.io/gorm"
)
type ...
-3
votes
1
answer
114
views
dial tcp 192.168.48.2:3306: connect: connection refused
My connection to the DB keeps getting refused i tried to make sure all the ports were correct and parameters were matched up but i still keep getting this error
this is my docker compose file
...
0
votes
0
answers
31
views
GORM many2many Association Replace not working as expected
I have a GO application using GIN and GORM. I want to create a Roles + Capabilities database. A role can have multiple capabilities and a capability can be in multiple roles. I created the following ...
1
vote
0
answers
41
views
How to deploy a SQLite Database with a GO application
I have an application structured more or less like the following :
app
api
database
db.go
main.go
data
database
data.db
ui
I would like to connect as a ...
1
vote
0
answers
33
views
Select Data from Two Tables without a Join (Cartesian Product) in Gorm
I'm trying to select data from two SQL tables without a join. Essentially, I need a Cartesian Product of the two tables. The SQL statement I expect to use is: SELECT * FROM table1, table2 WHERE table1....