From f03f6e90c725a1de9e2b62e8e4aeab5ff6ec4b80 Mon Sep 17 00:00:00 2001 From: Stefan Majewsky Date: Sat, 18 Apr 2026 17:35:07 +0200 Subject: add StructTagKeyIs Forgot this in 0.1.0. Without this, I cannot migrate existing Gorp users because Gorp does not understand `db:",auto"`. --- oblast.go | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'oblast.go') diff --git a/oblast.go b/oblast.go index 52c0cfd..338f245 100644 --- a/oblast.go +++ b/oblast.go @@ -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 { -- cgit v1.2.3