I have an CSV file of concerts. When parsing, I have already created the country “usa” as there are thousands of them in this file. Instead of hitting the db, I create the entry ahead of time into the var usa_country_id.
usa_country_id = fetch_or_insert_country("usa")
...
def fetch_or_insert_country(country) do
Repo.get_by(Country, country: country) || Repo.insert!(%Country{country: country})
end
Perfect - works great. But, for some reason, I get this warning with the code when I set the country_id for a save later:
country_id = if country == 'usa', do: usa_country_id, else: fetch_or_insert_country(country).country_id
warning: single-quoted strings represent charlists. Use ~c"" if you indeed want a
charlist or use "" instead
What am I doing wrong? Is there a better style to write this, say with pattern matching?