     assemble [select, from, join, where, group_by, order_by, limit]
   end
 
+  def update_all(%Ecto.Query{joins: [_ | _]}) do
+    raise ArgumentError, "JOINS are not supported on UPDATE statements by SQLite"
+  end
   def update_all(query) do
-    if query.joins != [] do
-      raise ArgumentError, "JOINS are not supported on UPDATE statements by SQLite"
-    end
-
     sources = create_names(query, :update)
     {table, _name, _model} = elem(sources, 0)
     fields = update_fields(query.updates, sources)

  end

  defp order_by(order_bys, sources) do
    exprs = Enum.map_join(order_bys, ", ", fn %QueryExpr{expr: expr} ->
      Enum.map_join(expr, ", ", &ordering_term(&1, sources))
    end)

    if exprs == "" do
      []
    else
      ["ORDER BY", exprs]
    end
  end

  defp ordering_term({:asc, expr}, sources), do: assemble(expr(expr, sources))
  defp ordering_term({:desc, expr}, sources) do

  end

  defp group_by(group_bys, havings, sources) do
    Enum.map_join(group_bys, ", ", fn %QueryExpr{expr: expr} ->
      Enum.map_join(expr, ", ", &assemble(expr(&1, sources)))
    end)
    |> group_by_clause(havings, sources)
  end

  defp group_by_clause("", _, _), do: []
  defp group_by_clause(exprs, havings, sources) do
    ["GROUP BY", exprs, having(havings, sources)]
  end

  defp having([], _sources), do: []
