Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(pagination): quote function broken for mysql #716

Merged
merged 1 commit into from
Aug 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions pagination/keysetpagination/paginator.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,11 @@ func Paginate[I any, PI interface {
id := model.IDField()
tableName := model.Alias()
return func(q *pop.Query) *pop.Query {
eid := q.Connection.Dialect.Quote(tableName + "." + id)
quote := q.Connection.Dialect.Quote
eid := quote(tableName) + "." + quote(id)

quoteAndContextualize := func(name string) string {
return q.Connection.Dialect.Quote(tableName + "." + name)
return quote(tableName) + "." + quote(name)
}
p.multipleOrderFieldsQuery(q, id, model.Columns().Cols, quoteAndContextualize)

Expand Down
2 changes: 1 addition & 1 deletion pagination/keysetpagination/paginator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func TestPaginator(t *testing.T) {
q = q.Scope(Paginate[testItem](paginator))

sql, args := q.ToSQL(&pop.Model{Value: new(testItem)})
assert.Equal(t, "SELECT test_items.created_at, test_items.pk FROM test_items AS test_items WHERE `test_items.pk` > ? ORDER BY `test_items.pk` ASC LIMIT 11", sql)
assert.Equal(t, "SELECT test_items.created_at, test_items.pk FROM test_items AS test_items WHERE `test_items`.`pk` > ? ORDER BY `test_items`.`pk` ASC LIMIT 11", sql)
assert.Equal(t, []interface{}{"token"}, args)
})

Expand Down
Loading