Connection error, database has. In the title

I am trying to debug a SQL Server database error in one of our rails applications. The problem is that the database name added to database.yaml has '.'

( 'testdb.v1'

) in it . This results in an error:

TinyTds::Error: Database 'testdb' does not exist. Make sure that the name is entered correctly.

      

Thinking this is a YAML vs. Rails quoting "." I opened my app in rails console and tried every kind of Ruby citation I could think of, but I get the same error every time.

Somewhere down the line from the database name assignment in mine model.connection_config

, '.' is interpreted as a format specifier, and the suffix is ​​removed from the name. model.connection_config['database']

has 'testdb.v1'

, as it should be, but it is clear that is not what is being passed to SQL Server.

I wasn't sure if it was a rails issue or a SQL Server issue, although the C # app I throw together allows the database to be opened without issue. So I guess this is a rails / ActiveRecord issue. Unfortunately I have no way to change the name of the database.

Is there a way to quote '.' to have it support "." and the suffix in the database name?

+3


source to share


1 answer


Further research took me to the github page for activerecord-sqlserver-adapter

There I found problems 230 and 226 , with similar problems to mine. Apparently using '.' in the database, table or column names will present similar problems. Since they were created in 2012 and are still open, it looks like a fix will be coming soon. There are some ideas in the comments to make the monkey patch work. Guess what is the approach I have to take to get this to work.



UPDATE: For those facing a similar problem and the database name is the only problem (not tables or columns), the solution we went with was to shutdown the sqlserver adapter. We created a SQL user for each database and assigned this default database to that user. We then linked to the username, but left the database name at zero. In this case, SQL Server will connect to the default database.

+2


source







All Articles