     # result of func.().
     defp with_temp_table(pid, returning, func) do
       tmp = "t_" <> (:random.uniform |> Float.to_string |> String.slice(2..10))
-      fields = Enum.join(returning, ", ")
+      fields = returning |> Enum.map(&quote_id/1) |> Enum.join(", ")
       results = case do_exec(pid, "CREATE TEMP TABLE #{tmp} (#{fields})") do
         {:error, _} = err -> err
         _ -> func.(tmp)

    # and drop the trigger when done.  Returns the result of func.().
    defp with_temp_trigger(pid, table, tmp_tbl, returning, query, ref, func) do
      tmp = "tr_" <> (:random.uniform |> Float.to_string |> String.slice(2..10))
      fields = Enum.map_join(returning, ", ", &"#{ref}.#{&1}")
      sql = """
      CREATE TEMP TRIGGER #{tmp} AFTER #{query} ON main.#{table} BEGIN
          INSERT INTO #{tmp_tbl} SELECT #{fields};
      END;
      """

          case err do
            {:error, _} -> err
            _ ->
              fields = returning |> Enum.map(&quote_id/1) |> Enum.join(", ")
              do_query(pid, "SELECT #{fields} FROM #{tmp_tbl}", [], opts)
          end
        end)
      end)
