You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix SqlLiterals overriding query's retryable value
Most `visit` functions in the `ToSql` visitor that modify the
`collector`'s `retryable` value will change it unconditionally to
`false`. For example, if the visitor ever encounters a
`DeleteStatement`, we never want to retry the query, so `retryable =
false`. However, the `SqlLiteral` `visit` method would copy the
`SqlLiteral`s `retryable` attribute to the `collector`, whether it was
`true` or `false`. This is an issue because the `collector`'s final
`retryable` value ends up dependent on the order of `SqlLiteral`s
visited and can be incorrectly changed from `false` to `true`.
This commit fixes the issue by changing the `SqlLiteral` `visit` method
to only change the `collector`'s `retryable` value to `false` (and only if
the `SqlLiteral`'s `retryable` value is also `false`). This ensures that
`retryable` `SqlLiteral`s can never override a `collector`s `false`
`retryable` value.
A new test was added to exercise the bug, specifically that a
`retryable: true` `SqlLiteral` is visited after a `Node` that marks the
`collector` `retryable: false`. Additionally, the fix exposed the fact
that one of the tests incorrectly relied on the previous behavior
because none of the tests used a `collector` with `retryable: true`. To
be more realistic, `collector.retryable = true` was added to all of the
tests concerned with `retryable`, even though most of them are valid
tests without it (since `retryable: nil` is the default, asserting
`retryable: false` still correctly covers `ToSql` changing the value to
`false`).
0 commit comments