Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions server/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@ gem "interactor", "~> 3.0"

gem "ruby-odbc", git: "https://github.com/Multiwoven/ruby-odbc.git"

<<<<<<< HEAD
gem "multiwoven-integrations", "~> 0.34.6"
=======
gem "duckdb", "= 1.4.3.0" # Pin to match libduckdb v1.4.3 installed in CI/Docker
gem "multiwoven-integrations", "~> 0.43.0"
>>>>>>> d45f7e42a (chore(CE): Update Server Gemfile 0.43.0 (#2266))

gem "temporal-ruby", github: "coinbase/temporal-ruby"

Expand Down
9 changes: 9 additions & 0 deletions server/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1979,7 +1979,11 @@ GEM
multi_xml (0.7.2)
bigdecimal (~> 3.1)
multipart-post (2.4.1)
<<<<<<< HEAD
multiwoven-integrations (0.34.6)
=======
multiwoven-integrations (0.43.0)
>>>>>>> d45f7e42a (chore(CE): Update Server Gemfile 0.43.0 (#2266))
MailchimpMarketing
activesupport
async-websocket
Expand Down Expand Up @@ -2339,7 +2343,12 @@ DEPENDENCIES
kaminari
letter_opener
liquid
<<<<<<< HEAD
multiwoven-integrations (~> 0.34.6)
=======
maxminddb (~> 0.1.22)
multiwoven-integrations (~> 0.43.0)
>>>>>>> d45f7e42a (chore(CE): Update Server Gemfile 0.43.0 (#2266))
mysql2
newrelic_rpm
parallel
Expand Down
20 changes: 10 additions & 10 deletions server/lib/reverse_etl/utils/random_query_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ def self.build_random_record_query(sync_config)
existing_query = sync_config.model.query
query_type = sync_config.source.query_type || "raw_sql"

case query_type.to_sym
when :soql
return existing_query if query_type.to_sym == :soql

case sync_config.source.name
when "Bigquery"
"SELECT * FROM (#{existing_query}) AS subquery ORDER BY RAND()"
when "SqlServer"
"SELECT * FROM (#{existing_query.strip.chomp(';')}) AS subquery ORDER BY NEWID()"
when "IntuitQuickBooks", "Odoo"
existing_query
when :raw_sql
if sync_config.source.name == "Bigquery"
"SELECT * FROM (#{existing_query}) AS subquery ORDER BY RAND()"
elsif sync_config.source.name == "IntuitQuickBooks" || sync_config.source.name == "Odoo"
existing_query
else
"SELECT * FROM (#{existing_query}) AS subquery ORDER BY RANDOM()"
end
else
"SELECT * FROM (#{existing_query}) AS subquery ORDER BY RANDOM()"
end
end
end
Expand Down
19 changes: 19 additions & 0 deletions server/spec/lib/reverse_etl/utils/random_query_builder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,25 @@ module Utils
end
end

context "when query_type is raw_sql and source is SqlServer" do
# SqlServer may not be in the installed multiwoven-integrations gem yet;
# exercise the builder with a protocol-shaped double.
let(:sync_config) do
double(
"SyncConfig",
model: double("Model", query: existing_query),
source: double("Source", name: "SqlServer", query_type: "raw_sql")
)
end

it "returns the query with ORDER BY NEWID()" do
query = described_class.build_random_record_query(sync_config)

expected_query = "SELECT * FROM (#{existing_query}) AS subquery ORDER BY NEWID()"
expect(query).to eq(expected_query)
end
end

context "when query_type is raw_sql and source is Intuit QuickBooks" do
let(:sync) do
create(:sync, model:, source: source_intuitquickbooks, destination:)
Expand Down
Loading