go-ozzo / ozzo-dbx

A Go (golang) package that enhances the standard database/sql package by providing powerful data retrieval methods as well as DB-agnostic query building capabilities.
MIT License
634 stars 90 forks source link

SelectQuery.FieldMapper isn't set by NewSelectQuery #36

Closed nkovacs closed 7 years ago

nkovacs commented 7 years ago

If you do this:

err := db.Select().Model(id, &model)

db's FieldMapper is not passed down to SelectQuery, so if the primary key has a different name in the database, it will fail.

nkovacs commented 7 years ago

I wrote a fix, but it breaks backwards compatibility because NewSelectQuery has changed: https://github.com/nkovacs/ozzo-dbx/commit/3867baf6ecc2dd0c2c071818d89300b9e6915935

qiangxue commented 7 years ago

Thank you for reporting this issue and finding a fix for it!