Sha256: e7f9699fc7d683fa788e92b662d80e6e70fe473799a14ca9b522fc44b5e80c52

Contents?: true

Size: 1.14 KB

Versions: 52

Compression:

Stored size: 1.14 KB

Contents

# frozen_string_literal: true

module Multiwoven
  module Integrations::Core
    class SourceConnector < BaseConnector
      # accepts Protocol::SyncConfig
      def read(_sync_config)
        raise "Not implemented"
        # setup sync configs
        # call query(connection, query)
        # Returns list of RecordMessage
      end

      private

      # This needs to be implemented as private method
      # In every source connector. This will be used for model preview
      def query(connection, query)
        # return list of RecordMessage
      end

      def batched_query(sql_query, limit, offset)
        offset = offset.to_i
        limit = limit.to_i
        raise ArgumentError, "Offset and limit must be non-negative" if offset.negative? || limit.negative?

        # Removing any trailing semicolons
        sql_query.chomp!(";")

        # Checking if the query already has a LIMIT clause
        raise ArgumentError, "Query already contains a LIMIT clause" if sql_query.match?(/LIMIT \d+/i)

        # Appending the LIMIT and OFFSET clauses to the SQL query
        "#{sql_query} LIMIT #{limit} OFFSET #{offset}"
      end
    end
  end
end

Version data entries

52 entries across 52 versions & 2 rubygems

Version Path
etl-integrations-0.1.82 lib/multiwoven/integrations/core/source_connector.rb
etl-integrations-0.1.81 lib/multiwoven/integrations/core/source_connector.rb
multiwoven-integrations-0.1.76 lib/multiwoven/integrations/core/source_connector.rb
multiwoven-integrations-0.1.75 lib/multiwoven/integrations/core/source_connector.rb
multiwoven-integrations-0.1.74 lib/multiwoven/integrations/core/source_connector.rb
multiwoven-integrations-0.1.73 lib/multiwoven/integrations/core/source_connector.rb
multiwoven-integrations-0.1.72 lib/multiwoven/integrations/core/source_connector.rb
multiwoven-integrations-0.1.64 lib/multiwoven/integrations/core/source_connector.rb
multiwoven-integrations-0.1.63 lib/multiwoven/integrations/core/source_connector.rb
multiwoven-integrations-0.1.62 lib/multiwoven/integrations/core/source_connector.rb
multiwoven-integrations-0.1.61 lib/multiwoven/integrations/core/source_connector.rb
multiwoven-integrations-0.1.60 lib/multiwoven/integrations/core/source_connector.rb
multiwoven-integrations-0.1.59 lib/multiwoven/integrations/core/source_connector.rb
multiwoven-integrations-0.1.58 lib/multiwoven/integrations/core/source_connector.rb
multiwoven-integrations-0.1.57 lib/multiwoven/integrations/core/source_connector.rb
multiwoven-integrations-0.1.56 lib/multiwoven/integrations/core/source_connector.rb
multiwoven-integrations-0.1.55 lib/multiwoven/integrations/core/source_connector.rb
multiwoven-integrations-0.1.54 lib/multiwoven/integrations/core/source_connector.rb
multiwoven-integrations-0.1.53 lib/multiwoven/integrations/core/source_connector.rb
multiwoven-integrations-0.1.52 lib/multiwoven/integrations/core/source_connector.rb