gothinkster / elixir-phoenix-realworld-example-app

Exemplary real world application built with Elixir + Phoenix
https://realworld.io
MIT License
891 stars 139 forks source link

Cockroachdb issues tracker #27

Open fire opened 5 years ago

fire commented 5 years ago

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

  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 commented 5 years ago

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 commented 5 years ago

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

lbighetti commented 5 years ago

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?

fire commented 4 years ago

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