Skip to content

Changed behavior of ecto.gen.repo mix task in Elixir 1.9 #3148

@Eiji7

Description

@Eiji7

Hi, originally I wanted to place it in mailing lists as proposition, but found that's more like bug, because it does not work as same as before Elixir release 1.9.0.

First of all this does not produces any compile-time warning:

embed_template :config, """
use Mix.Config
config <%= inspect @app %>, <%= inspect @mod %>,
database: "<%= @app %>_<%= @base %>",
username: "user",
password: "pass",
hostname: "localhost"
"""

I believe that typical beginner may not even correct this. Just btw. I would like to ask if we should add warning in Mix.Config.__using__/1 macro.

The bigger problem is here:

File.write! "config/config.exs",
String.replace(contents, "use Mix.Config\n", config_template(opts))

If we would have import Config then repo configuration would just not be added - this part looks like a bug for me as general behavior (adding config) is changed (not working as expected).

I suggest to add check like:

Version.match? "1.9.0", Mix.Project.config()[:elixir]

and store first config line in a variable.

Is it ok to make PR for this one right now or it should be discussed on mailing lists before it?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions