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 tracking_column regression with Postgresql Numeric types #17

Merged
merged 2 commits into from
Feb 4, 2020

Conversation

robbavey
Copy link
Contributor

@robbavey robbavey commented Feb 3, 2020

Prior to logsatash-input-jdbc 4.3.14, it was possible to use
the Postgresql Numeric type as a tracking column across Logstash
runs. Since 4.3.14, the deserialization of the sql_last_run
parameter has been broken for BigDecimal types, which is how
Numeric types are represented as Ruby BigDecimal objects by the
Sequel library we use in this plugin.

This commit restores this functionality.

Fixes: logstash-plugins/logstash-input-jdbc#371

Prior to logsatash-input-jdbc 4.3.14, it was possible to use
the Postgresql Numeric type as a tracking column across Logstash
runs. Since 4.3.14, the deserialization of the sql_last_run
parameter has been broken for BigDecimal types, which is how
Numeric types are represented as Ruby BigDecimal objects by the
Sequel library we use in this plugin.

This commit restores this functionality.

Fixes: logstash-plugins/logstash-input-jdbc#371
@elasticsearch-bot elasticsearch-bot self-assigned this Feb 4, 2020
@@ -62,7 +62,7 @@ def common_set_initial(method_symbol, default)

class NumericValueTracker < ValueTracking
def set_initial
common_set_initial(:gcd, 0)
common_set_initial(:abs, 0)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect the error before was due to the fact that BigDecimal hasn't gcd method.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And the gcd(x, 0) was a little bit trickie way to get the absolute value of x

@andsel
Copy link
Contributor

andsel commented Feb 4, 2020

LGTM

@andsel andsel assigned robbavey and unassigned elasticsearch-bot Feb 4, 2020
@robbavey robbavey merged commit be8412b into logstash-plugins:master Feb 4, 2020
@robbavey
Copy link
Contributor Author

robbavey commented Feb 4, 2020

Thanks @andsel!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

JDBC input does not work with PostgresSql numeric column.
3 participants