These are chat archives for jinzhu/gorm

22nd
Mar 2016
Jinzhu
@jinzhu
Mar 22 2016 06:07
@tboerger refer https://github.com/jinzhu/gorm/blob/master/dialects/mssql/mssql.go for how to add/remove callback
Thomas Boerger
@tboerger
Mar 22 2016 10:03
damn... i also tried to integrate tidb but there i'm getting totally different errors :(
This message was deleted
Adrian Sampaleanu
@asampal
Mar 22 2016 13:37
@jinzhu how do you have Gorm log generated SQL? The documentation on customizing logging isn't that clear. db.LogMode(true) doesn't seem to do it and the suggestion db.SetLogger(gorm.Logger{revel.TRACE}) doesn't help (I assume that is supposed to say level.Trace, but where is that level defined?).
Matthias Loibl
@metalmatze
Mar 22 2016 15:07

Hey, I join multiple tables and get the newest Post created by a User. Now for the User this works perfectly, but for the nested Post it doesn’t. What am I missing?

Don’t take this example to seriously, it’s just an example. I think some parts in the structs are missing :wink:
https://gist.github.com/MetalMatze/c8a0509069142533780a

Thanks!

Matthias Loibl
@metalmatze
Mar 22 2016 18:53
Same problem different attempt. From the docs I can only see that Preload does WHERE conditions? In my case I'd rather need ORDER BY and LIMIT. Is that somehow possible?
I've worked alot with eloquent ORM from laravel (PHP) where it is possible to do just that by passing a closure.
https://laravel.com/docs/5.2/eloquent-relationships#constraining-eager-loads
Jinzhu
@jinzhu
Mar 22 2016 23:20
@asampal GORM will pass some raw values to the logger, it will use those values to generate the log, refer logger.go
@MetalMatze Preload support inline conditions
So this is possible
Matthias Loibl
@metalmatze
Mar 22 2016 23:23
But in the examples there's only ("bla", "foo = ?", "bar") which translates to a WHERE foo = bar. How would this be possible?
Jinzhu
@jinzhu
Mar 22 2016 23:23
jinzhu/gorm@5883c70
@MetalMatze ahh, seems like those document doesn't exist in the github pages now, let me add that
Matthias Loibl
@metalmatze
Mar 22 2016 23:25
Ha, perfect! Just perfect.
Yeah, it's not in the docs. Thank you so much! I'll try to use it and get rid of my bad n+1 query I've built... :D
Jinzhu
@jinzhu
Mar 22 2016 23:26
cool ;)
Jinzhu
@jinzhu
Mar 22 2016 23:27
Yes, will add this one the the github page