circles-learning-labs / ecto_adapters_dynamodb

DynamoDB adapter for Elixir's Ecto Database layer.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add "recursive" config option

darrenklein opened this issue · comments

Allow users to set a boolean recursive config variable, for use in scans/queries.

Any inline option would always override the set value.

Should it default true or false?

Seems our default behavior for scans and queries is currently set up to not apply and apply the recursive options, respectively -

query.ex

  @doc """
  Formats the recursive option according to whether the query is a DynamoDB scan or query. (The adapter defaults to recursive fetch in case of the latter but not the former)
  """
  def parse_recursive_option(scan_or_query, opts) do
    case opts[:page_limit] do
      page_limit when (is_integer page_limit) and page_limit > 0 ->
        page_limit

      page_limit when (is_integer page_limit) and page_limit < 1 ->
        raise ArgumentError, message: "#{inspect __MODULE__}.parse_recursive_option/2 error: :page_limit option must be greater than 0."

      _ when scan_or_query == :scan ->
        # scan defaults to no recursion, opts[:recursive] must equal true to enable it
        opts[:recursive] == true

      _ when scan_or_query == :query ->
        # query defaults to recursion, opts[:recursive] must equal false to disable it
        opts[:recursive] != false
    end
  end

@alhambra1 given that we already apply these default behaviors, I'm not sure we need the config option after all. Do you concur?