oban-bg / oban

💎 Robust job processing in Elixir, backed by modern PostgreSQL and SQLite3
https://oban.pro
Apache License 2.0
3.35k stars 311 forks source link

Oban 2.16 breaks SQLite tests #959

Closed evilmarty closed 1 year ago

evilmarty commented 1 year ago

Precheck

Environment

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.

sorentwo commented 1 year ago

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

evilmarty commented 1 year ago

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

sorentwo commented 1 year ago

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