func TABLE(name string) *Table { if name == "" { panic("Null for table name is not allowed.") } this := new(Table).As(dbx.ToCamelCase(name)) this.columnsMap = coll.NewLinkedHashMap() this.columns = coll.NewLinkedHashSet() this.keys = coll.NewLinkedHashSet() this.name = name AddEntity(this) return this }
func (this *Table) COLUMN(name string) *Column { col := new(Column) col.name = name col.alias = dbx.ToCamelCase(name) col.table = this if !this.columns.Contains(col) { this.columns.Add(col) // checks if this column alias uniqueness if _, ok := this.columnsMap.Get(Str(col.GetAlias())); ok { panic(fmt.Sprintf("The alias '%s' for the column '%s' is not unique!", col.GetAlias(), col.String())) } else { this.columnsMap.Put(Str(col.GetAlias()), col) } } return col }