db icon indicating copy to clipboard operation
db copied to clipboard

Insert with no values does not produce valid SQL

Open zlangley opened this issue 9 years ago • 1 comments

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.

zlangley avatar Dec 27 '16 16:12 zlangley

Nice, we can definitely do that, thanks for the clarification @zlangley.

xiam avatar Jan 05 '17 22:01 xiam