示例#1
0
文件: Table.go 项目: quintans/goSQL
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
}
示例#2
0
文件: Table.go 项目: quintans/goSQL
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
}