[JIRA] Created: (ACTIVERECORD_JDBC-99) rake db:create sometimes silently does nothing on MS SQL Server
- From: "cjeris (JIRA)" <jira-no-reply@kenai.com>
- To: issues@activerecord-jdbc.kenai.com
- Subject: [JIRA] Created: (ACTIVERECORD_JDBC-99) rake db:create sometimes silently does nothing on MS SQL Server
- Date: Wed, 3 Mar 2010 17:49:11 +0000 (GMT+00:00)
rake db:create sometimes silently does nothing on MS SQL Server
---------------------------------------------------------------
Key: ACTIVERECORD_JDBC-99
URL: http://kenai.com/jira/browse/ACTIVERECORD_JDBC-99
Project: activerecord-jdbc
Issue Type: Bug
Components: MS SQL Server
Affects Versions: 0.9.2
Environment: Windows 2008 Enterprise Server, JRuby 1.4.0, Rails
2.3.5, AR-JDBC 0.9.2, SQL Server 2005, MS SQL Server JDBC driver 2.0
Reporter: cjeris
Attachments: patch2
With certain combinations of configuration data in database.yml, rake
db:create silently does nothing instead of creating the database.
If one specifies
url: jdbc:sqlserver://ser.ver.ip.addr\INSTANCE;databaseName=dbname
then the call to ActiveRecord::Base.connection at jdbc.rake:52 fails to
connect because the database has not yet been created. Then the calls
starting at line 59 fail because they have the same arguments.
If instead one specifies
url: jdbc:sqlserver://ser.ver.ip.addr\INSTANCE
database: dbname
then the calls at jdbc.rake:51-52 succeed, because the database name is not
added to the jdbc url at any point, so one gets a connection with no database
specified; but success of connection is taken as proof that the database
exists, so the task silently does nothing.
A partial fix for this problem is attached. It consists of adding a method
::JdbcSpec::ActiveRecordExtensions#mssql_connection which composes a JDBC URL
from supplied connection properties and then transfers to jdbc_connection;
and adding lib/active_record/connection_adapters/mssql_adapter.rb which just
requires jdbc_adapter.
There are at least two problems with this fix.
1. One has to write 'adapter: mssql' instead of 'adapter: jdbc' in
database.yml to get AR to call the mssql_connection adapter method. This
seems wrong -- should I be smashing any other mssql adapter? -- but I'm not
sure how to do it otherwise.
2. The fix only handles the case where you supply all the other connection
properties, and let mssql_connection compose the JDBC URL for you. There
should be some code called by jdbc.rake in the failure case (lines 59 et seq)
which munges the JDBC URL in the proper way if you supplied that yourself
instead of the properties from which it's built. I'm not sure where to put
this extension to live in harmony with the rest of the adapter.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://kenai.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
|
[JIRA] Created: (ACTIVERECORD_JDBC-99) rake db:create sometimes silently does nothing on MS SQL Server |
cjeris (JIRA) | 03/03/2010 |





