From 8670a1cf2777b21476958f521e79a46e2d8597ba Mon Sep 17 00:00:00 2001 From: grzegorz_skupiewski Date: Thu, 9 Jan 2025 17:39:10 +0100 Subject: [PATCH 1/2] add method to retrieve alias from view struct --- dialect/mysql/view.go | 4 ++++ dialect/psql/view.go | 4 ++++ dialect/sqlite/view.go | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/dialect/mysql/view.go b/dialect/mysql/view.go index 9e6c9518..42b974a9 100644 --- a/dialect/mysql/view.go +++ b/dialect/mysql/view.go @@ -56,6 +56,10 @@ func (v *View[T, Tslice]) NameAs() bob.Expression { return v.Name().As(v.alias) } +func (v *View[T, Tslice]) Alias() string { + return v.alias +} + // Returns a column list func (v *View[T, Tslice]) Columns() orm.Columns { // get the schema diff --git a/dialect/psql/view.go b/dialect/psql/view.go index 982820ef..34e15e5e 100644 --- a/dialect/psql/view.go +++ b/dialect/psql/view.go @@ -74,6 +74,10 @@ func (v *View[T, Tslice]) NameAs() bob.Expression { return v.Name().As(v.alias) } +func (v *View[T, Tslice]) Alias() string { + return v.alias +} + // Returns a column list func (v *View[T, Tslice]) Columns() orm.Columns { // get the schema diff --git a/dialect/sqlite/view.go b/dialect/sqlite/view.go index 5970c4fb..d21dbf59 100644 --- a/dialect/sqlite/view.go +++ b/dialect/sqlite/view.go @@ -74,6 +74,10 @@ func (v *View[T, Tslice]) NameAs() bob.Expression { return v.Name().As(v.alias) } +func (v *View[T, Tslice]) Alias() string { + return v.alias +} + // Returns a column list func (v *View[T, Tslice]) Columns() orm.Columns { // get the schema From 09ce6a8d813a3e33a9a4eb9c85d1d3aa28dc32c1 Mon Sep 17 00:00:00 2001 From: grzegorz_skupiewski Date: Fri, 10 Jan 2025 09:13:38 +0100 Subject: [PATCH 2/2] update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9fb20fc9..fa2db9d2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Added a `QueryTemplate` field to `bobgen_helpers.Templates` for drivers to include additional templates for queries. - Added a new reserved output key `queries`. This is handled specially for each query folder supplied by the driver. - Added new `wm` package to each dialect for mods that modify `Window` clauses. +- Added a new method `Alias` for `View` struct, for each dialect. It returns the alias of the view. ### Changed