-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: cursor query builder skip for empty condition
- Loading branch information
Showing
5 changed files
with
50 additions
and
11 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
integrations/lib/multiwoven/integrations/destination/sftp/config/spec.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,6 +42,42 @@ module Utils # rubocop:disable Metrics/ModuleLength | |
expect(results.last.size).to eq(100) | ||
end | ||
end | ||
context "when both cursor_field is empty" do | ||
let(:existing_query) { "SELECT * FROM table" } | ||
let(:source) { create(:connector, connector_type: "source", connector_name: "Snowflake") } | ||
let(:destination) { create(:connector, connector_type: "destination") } | ||
let!(:catalog) { create(:catalog, connector: destination) } | ||
let(:model) { create(:model, connector: source, query: existing_query) } | ||
let(:sync) do | ||
create(:sync, model:, source:, destination:, cursor_field: "") | ||
end | ||
let(:record) do | ||
Multiwoven::Integrations::Protocol::RecordMessage.new(data: { "id" => 1, "email" => "[email protected]", | ||
"first_name" => "John", "Last Name" => "Doe" }, | ||
emitted_at: DateTime.now.to_i).to_multiwoven_message | ||
end | ||
let(:record1) do | ||
Multiwoven::Integrations::Protocol::RecordMessage.new(data: { "id" => 1, "email" => "[email protected]", | ||
"first_name" => "John", "Last Name" => "Doe" }, | ||
emitted_at: DateTime.now.to_i).to_multiwoven_message | ||
end | ||
|
||
it "executes batches and not call CursorQueryBuilder for cursor_field is empty" do | ||
params = { | ||
offset: 0, | ||
limit: 100, | ||
batch_size: 100, | ||
sync_config: sync.to_protocol, | ||
client: | ||
} | ||
allow(client).to receive(:read).and_return(*Array.new(1, [record]), []) | ||
expect(CursorQueryBuilder).not_to receive(:build_cursor_query).with(sync.to_protocol, "") | ||
results = [] | ||
BatchQuery.execute_in_batches(params) do |result, _current_offset, _last_cursor_field_value| | ||
results << result | ||
end | ||
end | ||
end | ||
context "when both cursor_field is present" do | ||
let(:existing_query) { "SELECT * FROM table" } | ||
let(:source) { create(:connector, connector_type: "source", connector_name: "Snowflake") } | ||
|