go-jet / jet

Type safe SQL builder with code generation and automatic query result data mapping
Apache License 2.0
2.52k stars 118 forks source link

Added a global `UseSchema` method to table generation #194

Closed realbucksavage closed 1 year ago

realbucksavage commented 1 year ago

Adds a convenience method that can be used to change the schema name for all generated table instances. This could be a potential solution to #79 where you would want to use schema names dynamically in your program.

This could let you do things like this:

package main

import (
  // ...
  "mymodule.com/gen/dvds/table"
  "mymodule.com/gen/dvds/view"
)

func main() {
  // ...
  schemaName := determineSchemaName()
  table.UseSchema(schemaName)
  view.UseSchema(schemaName)
}

Passing an empty string to SetSchema would cause the queries to run in the schema specified in the DSN used to create DB connection.

codecov-commenter commented 1 year ago

Codecov Report

Merging #194 (199bb2a) into master (c9e627d) will increase coverage by 0.03%. The diff coverage is 100.00%.

:exclamation: Current head 199bb2a differs from pull request most recent head 1bf48d6. Consider uploading reports for the commit 1bf48d6 to get more accurate results

@@            Coverage Diff             @@
##           master     #194      +/-   ##
==========================================
+ Coverage   92.74%   92.78%   +0.03%     
==========================================
  Files         116      116              
  Lines        6903     6940      +37     
==========================================
+ Hits         6402     6439      +37     
  Misses        400      400              
  Partials      101      101              
Impacted Files Coverage Δ
generator/template/process.go 93.92% <100.00%> (+1.06%) :arrow_up:

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.