diff --git a/server/Gemfile b/server/Gemfile index 574ac981..3e2d34a8 100644 --- a/server/Gemfile +++ b/server/Gemfile @@ -13,7 +13,7 @@ gem "interactor", "~> 3.0" gem "ruby-odbc", git: "https://github.com/Multiwoven/ruby-odbc.git" -gem "multiwoven-integrations", "~> 0.3.0" +gem "multiwoven-integrations", "~> 0.3.1" gem "temporal-ruby", github: "coinbase/temporal-ruby" diff --git a/server/Gemfile.lock b/server/Gemfile.lock index c66c2114..9047de63 100644 --- a/server/Gemfile.lock +++ b/server/Gemfile.lock @@ -108,20 +108,20 @@ GEM appsignal (3.7.5) rack ast (2.4.2) - async (2.12.0) + async (2.12.1) console (~> 1.25, >= 1.25.2) fiber-annotation - io-event (~> 1.6) - async-http (0.67.1) + io-event (~> 1.6, >= 1.6.5) + async-http (0.69.0) async (>= 2.10.2) - async-pool (>= 0.6.1) - io-endpoint (~> 0.10, >= 0.10.3) + async-pool (~> 0.7) + io-endpoint (~> 0.11) io-stream (~> 0.4) - protocol-http (~> 0.26.0) - protocol-http1 (~> 0.19.0) - protocol-http2 (~> 0.18.0) - traces (>= 0.10.0) - async-pool (0.6.1) + protocol-http (~> 0.26) + protocol-http1 (~> 0.19) + protocol-http2 (~> 0.18) + traces (>= 0.10) + async-pool (0.7.0) async (>= 1.25) async-websocket (0.26.2) async-http (~> 0.54) @@ -1730,7 +1730,7 @@ GEM dry-initializer (~> 3.0) dry-schema (>= 1.12, < 2) zeitwerk (~> 2.6) - duckdb (1.0.0.1) + duckdb (1.0.0.2) bigdecimal (>= 3.1.4) ecma-re-validator (0.4.0) regexp_parser (~> 2.2) @@ -1842,8 +1842,8 @@ GEM inflection (1.0.0) interactor (3.1.2) io-console (0.7.1) - io-endpoint (0.10.3) - io-event (1.6.4) + io-endpoint (0.11.0) + io-event (1.6.5) io-stream (0.4.0) irb (1.11.1) rdoc @@ -1892,7 +1892,7 @@ GEM msgpack (1.7.2) multi_json (1.15.0) multipart-post (2.4.1) - multiwoven-integrations (0.3.0) + multiwoven-integrations (0.3.1) activesupport async-websocket aws-sdk-athena @@ -1965,7 +1965,7 @@ GEM premailer (~> 1.7, >= 1.7.9) process_executer (1.1.0) protocol-hpack (1.4.3) - protocol-http (0.26.5) + protocol-http (0.26.6) protocol-http1 (0.19.1) protocol-http (~> 0.22) protocol-http2 (0.18.0) @@ -2114,9 +2114,9 @@ GEM faraday-multipart gli hashie - sorbet-runtime (0.5.11439) + sorbet-runtime (0.5.11447) stringio (3.1.0) - stripe (11.7.0) + stripe (12.0.0) strong_migrations (1.8.0) activerecord (>= 5.2) thor (1.3.0) @@ -2188,7 +2188,7 @@ DEPENDENCIES jwt kaminari liquid - multiwoven-integrations (~> 0.3.0) + multiwoven-integrations (~> 0.3.1) mysql2 newrelic_rpm parallel diff --git a/server/app/models/model.rb b/server/app/models/model.rb index 17cada85..6732ac96 100644 --- a/server/app/models/model.rb +++ b/server/app/models/model.rb @@ -20,7 +20,7 @@ class Model < ApplicationRecord validates :name, presence: true validates :query, presence: true validates :primary_key, presence: true - enum :query_type, %i[raw_sql dbt soql] + enum :query_type, %i[raw_sql dbt soql table_selector] belongs_to :workspace belongs_to :connector diff --git a/server/spec/models/model_spec.rb b/server/spec/models/model_spec.rb index 017e8a04..6e16e3a5 100644 --- a/server/spec/models/model_spec.rb +++ b/server/spec/models/model_spec.rb @@ -74,7 +74,7 @@ describe "query_type" do it "defines query_type enum with specified values" do - expect(Model.query_types).to eq({ "raw_sql" => 0, "dbt" => 1, "soql" => 2 }) + expect(Model.query_types).to eq({ "raw_sql" => 0, "dbt" => 1, "soql" => 2, "table_selector" => 3 }) end end end diff --git a/server/spec/requests/api/v1/models_controller_spec.rb b/server/spec/requests/api/v1/models_controller_spec.rb index f4a518a8..fef7697f 100644 --- a/server/spec/requests/api/v1/models_controller_spec.rb +++ b/server/spec/requests/api/v1/models_controller_spec.rb @@ -161,6 +161,21 @@ expect(response_hash.dig(:data, :attributes, :primary_key)).to eq(request_body.dig(:model, :primary_key)) end + it "creates a new model with query type table selector" do + request = request_body + request[:model][:query_type] = "table_selector" + post "/api/v1/models", params: request.to_json, headers: { "Content-Type": "application/json" } + .merge(auth_headers(user, workspace_id)) + + expect(response).to have_http_status(:created) + response_hash = JSON.parse(response.body).with_indifferent_access + expect(response_hash.dig(:data, :id)).to be_present + expect(response_hash.dig(:data, :attributes, :name)).to eq(request_body.dig(:model, :name)) + expect(response_hash.dig(:data, :attributes, :query)).to eq(request_body.dig(:model, :query)) + expect(response_hash.dig(:data, :attributes, :query_type)).to eq("table_selector") + expect(response_hash.dig(:data, :attributes, :primary_key)).to eq(request_body.dig(:model, :primary_key)) + end + it "returns fail viwer role" do workspace.workspace_users.first.update(role: viewer_role) post "/api/v1/models", params: request_body.to_json, headers: { "Content-Type": "application/json" }