Skip to content
This repository has been archived by the owner on Apr 17, 2018. It is now read-only.

Ability to open connection without database name #15

Closed
postmodern opened this issue Nov 18, 2011 · 2 comments
Closed

Ability to open connection without database name #15

postmodern opened this issue Nov 18, 2011 · 2 comments

Comments

@postmodern
Copy link
Member

This is possible to do with mysql/pg, but DataObjects seems to require the Database name. Is it possible to bypass this requirement?

@jpr5
Copy link
Member

jpr5 commented Nov 18, 2011

I've wanted this as well, for administrative functionality like testing if databases exist, creating them, etc.

AFAICT, it's not possible with the current URI-oriented design. My workaround was to connect to known-existing DBs ("mysql" for MySQL) and then use that repository.adapter's connection. However that only works with lax permissions.

@postmodern
Copy link
Member Author

It should be possible to implement this using the current URI model. When path is "" or "/", no database should be selected. This constraint is actually implemented in each C-extension.

https://github.com/datamapper/do/blob/master/do_mysql/ext/do_mysql/do_mysql.c#L230-232
https://github.com/datamapper/do/blob/master/do_postgres/ext/do_postgres/do_postgres.c#L397-399

These constraints could be removed from the C-extensions, and moved to dm-core or dm-rails, where you actually need to connect to a specific database.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants