oban-bg/oban

Oban 2.16 breaks SQLite tests

Closed this issue · 3 comments

Precheck

  • Do a quick search and make sure the bug has not yet been reported
  • For support, favor using the Elixir Forum, Slack, IRC, etc.
  • Be friendly and polite!

Environment

  • Oban Version: 2.16.1
  • PostgreSQL Version: NA
  • SQLite Version: 3.39.5
  • Elixir & Erlang/OTP Versions (elixir --version): 1.15.6 & OTP 26

Current Behaviour

This commit expands apply_where to include the fragment "? @> ?" which is not supported by SQLite. This tests that are using the helper functions from Oban.Testing.

Mix.install([
  {:ecto_sqlite3, "~> 0.11.0"},
  {:oban, "~> 2.16.0"}
])
defmodule MyApp.Repo do
  use Ecto.Repo, otp_app: :my_app, adapter: Ecto.Adapters.SQLite3
end
defmodule MyApp.Testing do
  use Oban.Testing, repo: MyApp.Repo, prefix: false
  def test do
    refute_enqueued(args: %{})
  end
end
{:ok, repo} = MyApp.Repo.start_link(name: nil, database: "myapp.db")
MyApp.Repo.put_dynamic_repo(repo)
Ecto.Migrator.up(MyApp.Repo, 1, Oban.Migration, dynamic_repo: repo)
Oban.start_link(repo: MyApp.Repo, engine: Oban.Engines.Lite, testing: :inline)
MyApp.Testing.test()

Which would give the following error:

** (Exqlite.Error) unrecognized token: "@"
SELECT 1 FROM "oban_jobs" AS o0 WHERE (o0."state" IN (SELECT value FROM JSON_EACH('["available","scheduled"]'))) AND (o0."args" <@ ?) LIMIT 1
    (ecto_sql 3.10.2) lib/ecto/adapters/sql.ex:1047: Ecto.Adapters.SQL.raise_sql_call_error/1
    (ecto_sql 3.10.2) lib/ecto/adapters/sql.ex:945: Ecto.Adapters.SQL.execute/6
    (ecto 3.10.3) lib/ecto/repo/queryable.ex:229: Ecto.Repo.Queryable.execute/4
    (ecto 3.10.3) lib/ecto/repo/queryable.ex:19: Ecto.Repo.Queryable.all/3
    (ecto 3.10.3) lib/ecto/repo/queryable.ex:134: Ecto.Repo.Queryable.exists?/3
    (oban 2.16.1) lib/oban/testing.ex:379: Oban.Testing.refute_enqueued/1
    #cell:setup:18: (file)

Expected Behaviour

In the previous version this would pass. This can be tested by changing the version of Oban in the above example.

Thanks for the report. You confirmed that pure elixir-space matching was necessary!

Thanks for fixing the issue. I see that 2.16.2 is out and has resolved my issue.

Fixed with 32e1839, but I used the wrong format and it didn't auto-close this issue.