Fix for SELECT_JSON_ARR generates incorrect order by, limit and offset clauses for mariadb.

This commit is contained in:
go-jet 2026-01-16 14:11:22 +01:00
parent adef2f9b1a
commit 7d4aa4cdab
4 changed files with 168 additions and 48 deletions

View file

@ -190,6 +190,10 @@ type ClauseOrderBy struct {
SkipNewLine bool
}
func (o *ClauseOrderBy) serialize(statementType StatementType, out *SQLBuilder, options ...SerializeOption) {
o.Serialize(statementType, out, options...)
}
// Serialize serializes clause into SQLBuilder
func (o *ClauseOrderBy) Serialize(statementType StatementType, out *SQLBuilder, options ...SerializeOption) {
if o.List == nil {
@ -219,6 +223,10 @@ type ClauseLimit struct {
Count int64
}
func (o *ClauseLimit) serialize(statementType StatementType, out *SQLBuilder, options ...SerializeOption) {
o.Serialize(statementType, out, options...)
}
// Serialize serializes clause into SQLBuilder
func (l *ClauseLimit) Serialize(statementType StatementType, out *SQLBuilder, options ...SerializeOption) {
if l.Count >= 0 {
@ -233,6 +241,10 @@ type ClauseOffset struct {
Count IntegerExpression
}
func (o *ClauseOffset) serialize(statementType StatementType, out *SQLBuilder, options ...SerializeOption) {
o.Serialize(statementType, out, options...)
}
// Serialize serializes clause into SQLBuilder
func (o *ClauseOffset) Serialize(statementType StatementType, out *SQLBuilder, options ...SerializeOption) {
if is.Nil(o.Count) {

View file

@ -136,6 +136,20 @@ func SaveJSONFile(v interface{}, testRelativePath string) {
throw.OnError(err)
}
func ReadJSONFile(t require.TestingT, testRelativePath string, dest any) {
if _, ok := t.(*testing.B); ok {
return // skip assert for benchmarks
}
filePath := getFullPath(testRelativePath)
fileJSONData, err := os.ReadFile(filePath) // #nosec G304
require.NoError(t, err)
err = json.Unmarshal(fileJSONData, dest)
require.NoError(t, err)
}
// AssertJSONFile check if data json representation is the same as json at testRelativePath
func AssertJSONFile(t require.TestingT, data interface{}, testRelativePath string) {
if _, ok := t.(*testing.B); ok {