Skip to content

Commit 1f38274

Browse files
committed
Properly quote all database names in rake helper methods.
1 parent ea87653 commit 1f38274

File tree

4 files changed

+14
-10
lines changed

4 files changed

+14
-10
lines changed

CHANGELOG

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11

22
MASTER
33

4+
* 2.3.8
5+
6+
* Properly quote all database names in rake helper methods. [Ken Collins]
7+
48

59
* 2.3.7
610

activerecord-sqlserver-adapter.gemspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Gem::Specification.new do |s|
22
s.name = "activerecord-sqlserver-adapter"
3-
s.version = "2.3.7"
4-
s.date = "2010-02-17"
3+
s.version = "2.3.8"
4+
s.date = "2010-06-07"
55
s.summary = "SQL Server 2000, 2005 and 2008 Adapter For Rails."
66
s.email = "ken@metaskills.net"
77
s.homepage = "http://github.com/rails-sqlserver"

lib/active_record/connection_adapters/sqlserver_adapter.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ def simplified_datetime
170170
class SQLServerAdapter < AbstractAdapter
171171

172172
ADAPTER_NAME = 'SQLServer'.freeze
173-
VERSION = '2.3.7'.freeze
173+
VERSION = '2.3.8'.freeze
174174
DATABASE_VERSION_REGEXP = /Microsoft SQL Server\s+(\d{4})/
175175
SUPPORTED_VERSIONS = [2000,2005,2008].freeze
176176
LIMITABLE_TYPES = ['string','integer','float','char','nchar','varchar','nvarchar'].freeze
@@ -420,7 +420,7 @@ def execute_procedure(proc_name, *variables)
420420

421421
def use_database(database=nil)
422422
database ||= @connection_options[:database]
423-
do_execute "USE #{database}" unless database.blank?
423+
do_execute "USE #{quote_table_name(database)}" unless database.blank?
424424
end
425425

426426
def outside_transaction?
@@ -753,7 +753,7 @@ def drop_database(database)
753753
retry_count = 0
754754
max_retries = 1
755755
begin
756-
do_execute "DROP DATABASE #{database}"
756+
do_execute "DROP DATABASE #{quote_table_name(database)}"
757757
rescue ActiveRecord::StatementInvalid => err
758758
if err.message =~ /because it is currently in use/i
759759
raise if retry_count >= max_retries
@@ -767,7 +767,7 @@ def drop_database(database)
767767
end
768768

769769
def create_database(database)
770-
do_execute "CREATE DATABASE #{database}"
770+
do_execute "CREATE DATABASE #{quote_table_name(database)}"
771771
end
772772

773773
def current_database
@@ -782,11 +782,11 @@ def charset
782782
# http://sqlserver2000.databases.aspfaq.com/how-do-i-drop-a-sql-server-database.html
783783
def remove_database_connections_and_rollback(database=nil)
784784
database ||= current_database
785-
do_execute "ALTER DATABASE #{database} SET SINGLE_USER WITH ROLLBACK IMMEDIATE"
785+
do_execute "ALTER DATABASE #{quote_table_name(database)} SET SINGLE_USER WITH ROLLBACK IMMEDIATE"
786786
begin
787787
yield
788788
ensure
789-
do_execute "ALTER DATABASE #{database} SET MULTI_USER"
789+
do_execute "ALTER DATABASE #{quote_table_name(database)} SET MULTI_USER"
790790
end if block_given?
791791
end
792792

test/connections/native_sqlserver_odbc/connection.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@
1010
:mode => 'ODBC',
1111
:host => 'localhost',
1212
:username => 'rails',
13-
:dsn => 'activerecord_unittest',
13+
:dsn => ENV['ACTIVERECORD_UNITTEST_DSN'] || 'activerecord_unittest',
1414
:database => 'activerecord_unittest'
1515
},
1616
'arunit2' => {
1717
:adapter => 'sqlserver',
1818
:mode => 'ODBC',
1919
:host => 'localhost',
2020
:username => 'rails',
21-
:dsn => 'activerecord_unittest2',
21+
:dsn => ENV['ACTIVERECORD_UNITTEST2_DSN'] || 'activerecord_unittest2',
2222
:database => 'activerecord_unittest2'
2323
}
2424
}

0 commit comments

Comments
 (0)