These are chat archives for jinzhu/gorm

Sep 2016
Tim Schuster
Sep 04 2016 10:22 UTC

I'm having a bit of a problem with GORM atm.
I'm trying to setup a tag system wherein tags can imply other tags, ie the Tag "Blog" implies the Tag "Text-Post"

I declared the struct as follows:

type Tag struct {
    Name string `gorm:"primary_key"`
    Implies []Tag `gorm:"many2many:implied_tags;"`

However, when I crete the tables, I get an error: duplicate column name: tag_name because the query used was CREATE TABLE "implied_tags" ("tag_name" varchar(255),"tag_name" varchar(255), PRIMARY KEY ("tag_name","tag_name")) (using SQLite3 and PostgreSQL)

Is there any way to declare a self-referencing relationship in GORM? I've tried some things I found stackoverflow, but doesn't seem to work...