Beispiel #1
0
// INSERT
func (this *PostgreSQLTranslator) GetSqlForInsert(insert *db.Insert) string {
	// insert generated by super
	sql := this.GenericTranslator.GetSqlForInsert(insert)

	// only ONE numeric id is allowed
	// if no value was defined for the key, it is assumed an auto number,
	// otherwise is a guid (or something else)
	singleKeyColumn := insert.GetTable().GetSingleKeyColumn()
	if !insert.HasKeyValue && singleKeyColumn != nil {
		str := tk.NewStrBuffer()
		str.Add(sql, " RETURNING ", this.overrider.ColumnName(singleKeyColumn))
		sql = str.String()
	}

	return sql
}
Beispiel #2
0
func (this *InsertBuilder) From(insert *db.Insert) {
	table := insert.GetTable()
	this.tablePart.Add(this.translator.TableName(table))
}