Add support for FETCH FIRST clause.

This commit is contained in:
go-jet 2024-02-07 11:07:50 +01:00
parent e03773a79e
commit e51ddd5506
3 changed files with 145 additions and 3 deletions

View file

@ -234,6 +234,29 @@ func (o *ClauseOffset) Serialize(statementType StatementType, out *SQLBuilder, o
}
}
// ClauseFetch struct
type ClauseFetch struct {
Count IntegerExpression
WithTies bool
}
// Serialize serializes ClauseFetch into sql builder output
func (o *ClauseFetch) Serialize(statementType StatementType, out *SQLBuilder, options ...SerializeOption) {
if is.Nil(o.Count) {
return
}
out.NewLine()
out.WriteString("FETCH FIRST")
o.Count.serialize(statementType, out, options...)
if o.WithTies {
out.WriteString("ROWS WITH TIES")
} else {
out.WriteString("ROWS ONLY")
}
}
// ClauseFor struct
type ClauseFor struct {
Lock RowLock