elixir-phoenix-realworld-example-app icon indicating copy to clipboard operation
elixir-phoenix-realworld-example-app copied to clipboard

Cockroachdb issues tracker

Open fire opened this issue 7 years ago • 4 comments

Trying cockroachdb on 2.1 beta (v2.1.0-beta.20181015):

  • Cannot create a database automatically, but can migrate with ecto.migrate (expected)
  • Getting list of tags fails Replaced query with:
  def list_tags do
    Ecto.Adapters.SQL.query!(Repo, "select count(*) as tag_count, ut.tag
    from articles, (select unnest(tag_list) from articles) as ut(tag)
    group by ut.tag
    order by tag_count desc limit 5;").rows
    |> Enum.map(fn v -> Enum.at(v, 1) end)
  end

fire avatar Oct 22 '18 18:10 fire

Also replaced:

  def filter_by_tags(query, tag) do
    query
    |> join(:inner, [a], p in fragment(
"""
      WITH articles AS( SELECT a.id, unnest(a.tag_list) tag FROM articles a ORDER BY a.id, a.created_at) select * from articles
"""), a.id == p.id)
    |> where([a], fragment("tag = ?", ^tag))
  end

fire avatar Oct 22 '18 22:10 fire

As of Cockroachdb 4.2.1 the subquery issue is gone, but the system doesn't work.

fire avatar Dec 03 '18 08:12 fire

Hi @fire I'm not sure I follow. This project uses Postgres as the DB, I believe there are more changes required to make it work with a different DB.

Can you share elixir / otp version and what are the changes you made to try to make this work?

lbighetti avatar Jan 17 '19 08:01 lbighetti

The same ecto driver for postgresql is able to be used for cockroachdb.

fire avatar Jan 04 '20 08:01 fire