diff options
| author | Stefan Majewsky <majewsky@gmx.net> | 2026-04-18 17:35:07 +0200 |
|---|---|---|
| committer | Stefan Majewsky <majewsky@gmx.net> | 2026-04-18 17:35:08 +0200 |
| commit | f03f6e90c725a1de9e2b62e8e4aeab5ff6ec4b80 (patch) | |
| tree | fdbfcbecde2f7ad647acaf1b339af3b028bc51c7 /oblast.go | |
| parent | a813a7cac33096c1e716cde89a52106664648895 (diff) | |
| download | go-oblast-f03f6e90c725a1de9e2b62e8e4aeab5ff6ec4b80.tar.gz | |
add StructTagKeyIs
Forgot this in 0.1.0. Without this, I cannot migrate existing Gorp users
because Gorp does not understand `db:",auto"`.
Diffstat (limited to 'oblast.go')
| -rw-r--r-- | oblast.go | 8 |
1 files changed, 8 insertions, 0 deletions
@@ -123,6 +123,14 @@ func PrimaryKeyIs(columnNames ...string) PlanOption { return func(opts *planOpts) { opts.PrimaryKeyColumnNames = columnNames } } +// StructTagKeyIs is a PlanOption for record types that allows renaming the struct tag key that Oblast inspects from its default value of "db". +// For example, providing StructTagKeyIs("oblast") means that a struct tag like `db:",auto"` must be written as `oblast:",auto"` instead. +// +// This is useful when migrating from or to another ORM library that uses the same `db:"..."` tag as Oblast, but with conflicting semantics. +func StructTagKeyIs(key string) PlanOption { + return func(opts *planOpts) { opts.StructTagKey = key } +} + // Handle is an interface for functions providing direct DB access. // It covers methods provided by both *sql.DB and *sql.Tx, thus allowing functions using it to be used both within and outside of transactions. type Handle interface { |
