db
db copied to clipboard
Insert with no values does not produce valid SQL
Using PostgreSQL and db.v2:
type Channel struct {
ID int64 `db:"id,omitempty"`
TimeCreated time.Time `db:"time_created,omitempty"`
}
func (sess *sqlbuilder.Database) CreateChannel() (*Channel, error) {
obj, err := sess.Collection("channel").Insert(&Channel{})
// Expected: INSERT INTO "channel" VALUES (default) RETURNING "id"
// Actual: INSERT INTO "channel" VALUES RETURNING "id"
}
An empty VALUES clause should be (default), but it is actually just an empty string.
Nice, we can definitely do that, thanks for the clarification @zlangley.