Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #10569 (closed enhancement: incomplete)

Opened 7 months ago

Last modified 6 months ago

[PATCH] Use MySQL as default database if the sqlite3 ruby bindings are not found

Reported by: jeff Assigned to: core
Priority: normal Milestone: 2.x
Component: Railties Version: edge
Severity: normal Keywords:
Cc:

Description

Sqlite3 is an excellent choice as the default database, except for Windows users where it is far less common to have sqlite already installed.

This patch will cause the app generator to use sqlite3 only if the sqlite3-ruby gem can be found, which is the best indicator that the user has sqlite3 properly installed.

If the ruby bindings are not found, rails falls back to using mysql as the default.

This patch also updates the --help documentation which still listed mysql as the default even though the code changed it to sqlite3.

Attachments

determine_best_default_database.diff (1.4 kB) - added by jeff on 12/19/07 20:30:29.

Change History

12/19/07 20:30:29 changed by jeff

  • attachment determine_best_default_database.diff added.

12/19/07 23:29:48 changed by thewoolleyman

how about a test?

12/19/07 23:34:19 changed by jeff

Can you suggest how I could write a test?

I just didn't see any existing tests for the app generator; and anyway I wasn't sure how to meaningfully mock up the default_database_method without adding unnecessary complexity to the code.

If anyone has any ideas, I'd be happy to try to incorporate something meaningful; I just wasn't sure how to proceed with that.

12/19/07 23:54:35 changed by mislav

+1

It could also be documented somewhere that installing sqlite3 on windows is just a matter of dropping an exe and dll into the "windows\system32" folder and then installing the gem.

12/20/07 03:37:20 changed by jeff

  • component changed from ActiveRecord to Railties.

12/20/07 05:15:17 changed by thewoolleyman

I guess it would clutter things to pull out hook methods to mock. Looks good.

+1

12/20/07 05:56:18 changed by jeff

  • keywords set to verified.

12/20/07 15:22:33 changed by blameMike

I will most likely adopt the new default of sqlite, but I can see where a lot of users may not want to use sqlite (e.g. Windows users as Jeff mentions). I think this is a solid idea.

+1.

12/20/07 15:34:13 changed by mdemare

+1

MySQL is pretty common on windows boxes, never heard of anybody using SQLLite there.

12/20/07 18:06:40 changed by matt

-1 what about conventions? What about a common standard? As far as I know none of Windows version ship with an open source DB? You do have to install MySQL don't you? On top of that, you can easily generate a new app supporting mysql so what's the big deal?

12/23/07 02:53:34 changed by chuyeow

Hmm I'd prefer if the generator emitted a helpful message on how to install sqlite3 and/or how to generate a new Rails app with other databases to address this scenario jeff raised in rubyonrails-core:

1. Windows developer wants to take the brave step of trying out Rails.
2. She picks up any Rails book on the market, finds out she needs to
install MySQL and the Ruby One-Click Installer, and does a gem install
rails
3. She types "rails hello_world" and creates one model
4. Big Problems

I think we should keep the default constant, but address the need to not scare off new developers (old developers should already know what they are doing anyway and I think we can assume they are largely unaffected by the sqlite3 change).

+1 to the idea, -1 to the current patch.

12/23/07 02:54:12 changed by chuyeow

Oh and I forgot to add that the patch doesn't apply cleanly now due to r8457.

01/03/08 00:04:25 changed by david

  • keywords deleted.
  • status changed from new to closed.
  • resolution set to incomplete.

I don't like falling back on MySQL either, but I really like warning people that they need to have the proper database adapter and engine installed. I think we should have this for the other adapters too, so that when people run rails -d mysql, it'll check for the adapter on that and so on.

Let's reopen when it works like that. Thanks for working on this, though. Just getting a weird error message is no good indeed.