-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from Multiwoven/fix/skip-cursor-field-empty-ee
fix: skip cursor query builder for cursor empty
- Loading branch information
Showing
2 changed files
with
39 additions
and
1 deletion.
There are no files selected for viewing
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,44 @@ 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") } | ||
|