Skip to content

Commit

Permalink
fixed support for MariaDB (#30)
Browse files Browse the repository at this point in the history
Co-authored-by: Tong Zhaoqi [email protected]
  • Loading branch information
roblaszczak authored Mar 28, 2024
1 parent ff18e90 commit 938906b
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions pkg/sql/schema_adapter_mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,11 @@ func (s DefaultMySQLSchema) batchSize() int {
func (s DefaultMySQLSchema) SelectQuery(topic string, consumerGroup string, offsetsAdapter OffsetsAdapter) Query {
nextOffsetQuery := offsetsAdapter.NextOffsetQuery(topic, consumerGroup)

selectQuery := `
SELECT offset, uuid, payload, metadata FROM ` + s.MessagesTable(topic) + `
WHERE
offset > (` + nextOffsetQuery.Query + `)
ORDER BY
offset ASC
LIMIT ` + fmt.Sprintf("%d", s.batchSize())
// It's important to wrap offset with "`" for MariaDB.
// See https://github.com/ThreeDotsLabs/watermill/issues/377
selectQuery := "SELECT `offset`, `uuid`, `payload`, `metadata` FROM " + s.MessagesTable(topic) +
" WHERE `offset` > (" + nextOffsetQuery.Query + ") ORDER BY `offset` ASC" +
` LIMIT ` + fmt.Sprintf("%d", s.batchSize())

return Query{Query: selectQuery, Args: nextOffsetQuery.Args}
}
Expand Down

0 comments on commit 938906b

Please sign in to comment.