goqu icon indicating copy to clipboard operation
goqu copied to clipboard

SqlServer dialect and table hint `With (NOLOCK)`

Open drgarcia1986 opened this issue 2 years ago • 0 comments

Is your feature request related to a problem? Please describe. How can I use table hints with sqlserver dialect?

Describe the solution you'd like I would like to create a SQL with (nolock) table hint, something like:

qb := goqu.Dialect("sqlserver")
ds := qb.From("test").Hint("NOLOCK").Where(goqu.Ex{"id": 10})
sql, args, err := ds.ToSql()
if err != nil {
    panic(err)
}
fmt.Println(sql, args)
SELECT * FROM "test" WITH (NOLOCK) WHERE ("id" = 10) []

Describe alternatives you've considered

Dialect

  • [ ] postgres
  • [ ] mysql
  • [ ] sqlite3
  • [X] sqlserver

Additional context About Table Hints

drgarcia1986 avatar Oct 06 '22 17:10 drgarcia1986