Where communities thrive

  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
Repo info
  • 13:43
    maxim-morozenko starred jinzhu/gorm
  • 13:11
    MJobLee starred jinzhu/gorm
  • 10:33
    cuongw starred jinzhu/gorm
  • 10:03
    fantasyRqg starred jinzhu/gorm
  • 09:51
    YahuiAn commented #2406
  • 09:47
    fcodetop commented #2315
  • 09:46
    fcodetop commented #2315
  • 09:46
    fcodetop commented #2315
  • 09:18
    YahuiAn commented #2406
  • 09:01
    srlemon opened #2811
  • 08:45
    fcodetop commented #2315
  • 08:45
    fcodetop commented #2315
  • 08:45
    fcodetop commented #2315
  • 08:43
    fcodetop commented #2315
  • 08:23
    blackbinbinbinbin starred jinzhu/gorm
  • 07:29
    yushine commented #2736
  • 06:55
    bhavyasree96 opened #2810
  • 06:06
    dirkarnez starred jinzhu/gorm
  • 03:55
    uplemon starred jinzhu/gorm
  • 03:51
    uplemon starred jinzhu/gorm
How can I change primary key? I don't want a composite primary key but I rather want a different field than the default "id" to be the primary key?
specifying a different field as primary_key makes it composite key with the "id".
Guess skipping to include gorm.Model works
Is there ORMy way of appending elements to an array? Or am I stuck with using raw SQL for this?
Paul I've had no problem with gorm converting time.Time to timestamp with time zone
The time type of my module is int, sorry, let everyone laugh.
Paul which is which?
Paul and which direction is the data going?
Slava Shklyar
@amarjeetanandsingh .Find(&perzUsers) return *gorm.DB... you need .Find(&perzUsers).Error
Nikhil Sharma
I have an object (Person) with a has many association with another object (Toy). How do I update a Toy to have it belong to a new Person?
Hi. Is there any option to set context to a query?
Charles Green
Hello, I'm working with Postgresql with a text[] column. Are text arrays supported?
I'm receiving the following error which I thought was caused by null values but confirmed the column does not have any nulls.
sql: Scan error on column index 7, name "odpt_destinationstation": unsupported Scan, storing driver.Value type []uint8 into type *[]string
Charles Green
Looks like the same cases as here.
All good. thanks.
Ask for advice:
db.Unscoped().Where("deleted_on != ? ", 0).Delete(&Tag{})
deleted_on is of type int
If deleted_on is a timestamp and the value is null, how should it be expressed?
Hi guys, i have the following query: db.Where("user_id = ?", tmpUser.ID).Find(&subscriptions), subscriptions is a slice of subscription struct
the problem is, that it will output also the relations
how can i query only the subscriptions where user_id = x without getting back the related objects to the subscription?

Can someone help me? How to change this query:

select count(t.) from (SELECT FROM table WHERE table = 'abc' LIMIT 12 OFFSET 12) AS t


Paul you can send plain queries to gorm if you wish
Paul but for the subqyery: http://gorm.io/docs/query.html#SubQuery
I dont want to use sqlbuilder because my parameters are dynamic (WHERE), im using subquery but is not working, Count dosent work w offset
db.Where("count(t.*)", db.Table("table t").Where("table = ?", abc).QueryExpr()).Row().Scan(&count), return 0
Paul log the sql and look at what gorm actually sends
Question, I am looking to do preloading. I make a call to preload and I see no error (which I had previously seen with the wrong preload value) but then I see no query occuring for the pre-loaded values. Who can I get them to actually performt the preload?
Stefanos Chrs
Hello is there a way to use types to write a join and not plain strings?
For example the following is as unsafe is as writing a raw sql, if the model changes the user.name to user.fullName then it is broken. Additionally you need to remember table names, column names where you have everything in the struct.
  Select("users.name, emails.email").
  Joins("left join emails on emails.user_id = users.id").
sina nadihagh
is anybody there?
I have a problem
please someone answer me
Hello , newbie to Golang
Massimiliano Bertinetti
@nadihagh very bad mood
Princewill Samuel
Hello has anyone done migrations that modify table structure (add, update or delete column(s)) using Gorm. I can't find anything in the docs on that
Gabriel Pickl
hey all, i got a small question. i have a model that contains time.Duration as a type, and currently I save that to the database by storing start and end time (in one case), or calculating the number of minutes/seconds the Duration represents (in other cases). Is there a way to encode this marshalling in gorm (like, define a function that is used instead of the object field)?
Gabriel Pickl
okay, some more searching got me to this: jinzhu/gorm#677
which scanner is jinzhu referring to here?
Short Stop

I have a really odd issue that I can't seem to work out. When I execute a preload for a certain struct, it runs the following SQL:

SELECT * FROM "articles" INNER JOIN "sub_article_hottest_caches" ON "sub_article_hottest_caches"."article_id" = "articles"."article_id" WHERE ("sub_article_hottest_caches"."article_cache_id" IN (954,90
8,909,905,898,899,900,901,902,903)) ORDER BY "sub_article_hottest_caches".rank ASC

Which returns 0 rows, however, running the same query in the DB returns many rows. What is going on here?

Short Stop

@jinzhu For whatever reason, the SQL builder seems to be building the string wrong:

With db.Exec:

[2019-12-11 00:45:29]  [1.00ms]
        SELECT * FROM "articles" INNER JOIN "sub_article_hottest_caches" ON "sub_article_hottest_caches"."article_id" = "articles"."article_id" WHERE ("sub_article_hottest_caches"."article_cache_id" IN (923,926,918,920,922,924,927,929,954,916))
[13 rows affected or returned ]

Using Preload:

[2019-12-11 00:45:29]  [2.00ms]  SELECT * FROM "articles" INNER JOIN "sub_article_hottest_caches" ON "sub_article_hottest_caches"."article_id" = "articles"."article_id" WHERE ("sub_article_hottest_caches"."article_cache_id" IN (954,91
[0 rows affected or returned ]
The list is put onto a new line when it should not be
go-gorm connection pool is not working,it creates lots of time_wait connections
help ~
Muhammad Alfan Miftakhul Hudha
guys can we use an args ~ map[string]interface{} with type slice in value i.e ["id"]= []int64{1,2}
i got this error
sql: converting argument $1 type: unsupported type []int64, a slice of int64
Hi is anyone online ?
i need help for my project ^^'
Eduardo Mior
how to put SSL_KEY and SSL_CERT in gorm? I'm hours trying to connect to a bank that uses SSL
I have some questions about HAS MANY relationship. Is there any gorm project example about that? Thanks!