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

Tracking column in mongo input not working #383

Open
DeNReLoaDeD opened this issue Sep 2, 2020 · 0 comments
Open

Tracking column in mongo input not working #383

DeNReLoaDeD opened this issue Sep 2, 2020 · 0 comments

Comments

@DeNReLoaDeD
Copy link

Hello,

tracking_column doesn't work when query statement is against mongo. Debugging, i've seen that response in jdbc.rb comes like this:

{:document => { ... mongo data ...}}

In this method 'get_column_value', line:

  if !row.has_key?(@tracking_column.to_sym)

row.has_key only evaluates the first level of the hash, so all nested keys are omitted. Because of this, always is showing the message 'tracking_column not found in dataset.

I've edited the code, as a workarround, to also check if it's in the second level of the hash, and if it is, pick the value from there (second if (!row.dig...)):

public
def get_column_value(row)
  if !row.has_key?(@tracking_column.to_sym)
    if !row.dig(:document, @tracking_column).nil?
          @sql_last_value = row.dig(:document, @tracking_column)
    elsif !@tracking_column_warning_sent
      @logger.warn("tracking_column not found in dataset.", :tracking_column => @tracking_column)
      @tracking_column_warning_sent = true
    end
    # If we can't find the tracking column, return the current value in the ivar
    @sql_last_value
  else
    # Otherwise send the updated tracking column
    row[@tracking_column.to_sym]
  end
end

Now, it's working fine. I'm not a ruby developer and i'm pretty sure that there are better ways to do this, so if it could be fixed would be awesome.

Thanks!

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

No branches or pull requests

1 participant