daraul
daraul

Reputation: 174

How can I get Rails to connect to a SQL Server database with a period in it's name?

I have to connect to a SQL Server database that I do not control. The name is something like "foo.bar-baz.aaa". I've configured the name in config/database.yml with database: foo.bar-baz.aaa. When I attempt to query any model in that database, rails complains that "Database 'foo' does not exist".

I'm figuring that somewhere in the query builder, that period between "foo", and "bar-baz" is causing some mayhem. Is there any way that I can work around this?

Upvotes: 1

Views: 54

Answers (1)

daraul
daraul

Reputation: 174

The answer turns out to be quoting the DB name, while also "delimit identifying" the name (as per Larnu's comment).

Now, my config/database.yml file has this configuration:

database: '[foo.bar-baz.aaa]'

Thanks to both BenFenner, and Larnu for pointing me in the right direction.

Upvotes: 1

Related Questions