Fix for dm-mysql2-adapter loading problem #154

wants to merge 1 commit into


None yet

4 participants


Added conditional for mysql2 adapter so that dm-mysql2-adapter isn't loaded. (the gem name is dm-mysql-adapter)

Many people are running into issues when they are using "mysql2" as the adapter in their database.yml file. The incorrect gem name is being loaded—causing rake tasks to fail.

Here is one example:

Thom Mahoney Added conditional for mysql2 adapter so that dm-mysql2-adapter isn't …
…loaded. (the gem name is dm-mysql-adapter)
solnic commented Oct 15, 2011

I think we should simply catch load error and show some meaningful message. Switching mysql2 => mysql is covering a typo in your config so I'm not sure if dm-core should be responsible for doing that. WDYT @dkubb?

dkubb commented Oct 15, 2011

I would be more inclined to move this into dm-rails, and have something that handles normalizing the stuff from user input, which is basically what database.yml is. I wouldn't want to include a hack to fix a hack, thereby perpetuating the style of "sub-standard coding" :P

dkubb commented Oct 15, 2011

Going to close this for now. Please submit a fix to dm-rails for this.

@dkubb dkubb closed this Oct 15, 2011

@solnic The use of "mysql2" in a database.yml is not a typo. See here:
From the README: "To use the ActiveRecord driver (with or without rails), all you should need to do is have this gem installed and set the adapter in your database.yml to "mysql2". That was easy right? :)"

@dkubb I appreciate your candor. I'll take a look at dm-rails to see where this can be added. The existing normalization done here in dm-core should probably be removed, though.

solnic commented Oct 16, 2011

@thommahoney DataMapper uses DataObject drivers and in the database.yml you specify adapter type, not driver. We could add some code to dm-rails that would handle 'mysql2' or inform the user that 'mysql' should be used instead

mltsy commented Oct 25, 2011

I just went into #datamapper and solnic helped me understand this: there is no need (for me) to use the 'mysql2' gem with DataMapper, because 'do-mysql' (the DataObject driver dm-mysql-adapter depends on to access MySQL repositories) doesn't have problems with character-encodings, which is the reason I (and most people, I would assume) use the 'mysql2' driver in ActiveRecord projects.

So if you've come here wondering why this isn't working - the answer is, unless I'm mistaken about why you're using 'mysql2', remove 'mysql2', you don't need it. do-mysql works just fine without it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment