Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI | add :types to query_option so dialyzer is happy #234

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

addUsername
Copy link

First, thank you for your awesome library!!

I've just update it to last version and everything works except the CI, dialyzer fails because :types (opt needed when RowBinary) is not included in query_option

Before this commit dialyzer fails with:

The function call will not succeed.

Ch.query(_pid :: any(), _query :: <<_::8, _::size(1)>>, _events :: [map()], [
  {:types, [binary()]},
  ...
])

will never return since the success typing is:
(
  atom()
  | pid()
  | {atom(), _}
  | {:via, atom(), _}
  | %DBConnection{:conn_mode => _, :conn_ref => reference(), :pool_ref => _},
  binary()
  | maybe_improper_list(
      binary() | maybe_improper_list(any(), binary() | []) | byte(),
      binary() | []
    ),
  any(),
  [
    {:command
     | :database
     | :deadline
     | :decode
     | :encode
     | :format
     | :headers
     | :log
     | :password
     | :queue
     | :settings
     | :timeout
     | :username,
     atom() | binary() | (map() -> any()) | [{_, _}] | integer() | {atom(), atom(), [any()]}}
  ]
) :: {:error, %{:__exception__ => true, :__struct__ => atom(), atom() => _}} | {:ok, _}

and the contract is
(DBConnection.conn(), iodata(), params, [query_option()]) ::
  {:ok, Ch.Result.t()} | {:error, Exception.t()}
when params: map() | [term()] | [row :: [term()]] | iodata() | Enumerable.t()

now it is happy:

$ mix dialyzer
Finding suitable PLTs
Checking PLT...
[ :ch,  ...]
Looking up modules in dialyxir_erlang-26.0.2_elixir-1.15.4_deps-dev.plt
Finding applications for dialyxir_erlang-26.0.2_elixir-1.15.4_deps-dev.plt
Finding modules for dialyxir_erlang-26.0.2_elixir-1.15.4_deps-dev.plt
Checking 463 modules in dialyxir_erlang-26.0.2_elixir-1.15.4_deps-dev.plt
Adding 2013 modules to dialyxir_erlang-26.0.2_elixir-1.15.4_deps-dev.plt
done in 0m55.57s
No :ignore_warnings opt specified in mix.exs and default does not exist.

Starting Dialyzer
[
  check_plt: false,
  init_plt: ~c"/app/_build/dev/dialyxir_erlang-26.0.2_elixir-1.15.4_deps-dev.plt",
  files: [ ...],
  warnings: [:unknown]
]
Total errors: 0, Skipped: 0, Unnecessary Skips: 0
done in 0m5.36s
done (passed successfully)

I hope i didn't mess up somewhere 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant