Skip to content

Commit 051ee46

Browse files
authored
Merge pull request #1008 from jruby/mssql-support
Work towards using activerecord-sqlserver-gem for mssql support
2 parents 09bad1a + b8f208a commit 051ee46

22 files changed

+305
-1989
lines changed

README.md

+11-9
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,16 @@
55
ActiveRecord-JDBC-Adapter (AR-JDBC) is the main database adapter for Rails'
66
*ActiveRecord* component that can be used with [JRuby][0].
77
ActiveRecord-JDBC-Adapter provides full or nearly full support for:
8-
**MySQL**, **PostgreSQL**, **SQLite3**. In the near future there are plans to
9-
add support **MSSQL**. Unless we get more contributions we will not be going
10-
beyond these four adapters. Note that the amount of work needed to get
11-
another adapter is not huge but the amount of testing required to make sure
12-
that adapter continues to work is not something we can do with the resources
13-
we currently have.
8+
**MySQL**, **PostgreSQL**, **SQLite3** and **MSSQL*** (SQLServer).
149

15-
For Oracle database users you are encouraged to use
16-
https://github.com/rsim/oracle-enhanced.
10+
Unless we get more contributions we will not be supporting more adapters.
11+
Note that the amount of work needed to get another adapter is not huge but
12+
the amount of testing required to make sure that adapter continues to work
13+
is not something we can do with the resources we currently have.
14+
15+
- for **Oracle** database users you are encouraged to use
16+
https://github.com/rsim/oracle-enhanced
17+
- **MSSQL** adapter's gem parts reside in a [separate repository][8]
1718

1819
Version **50.x** supports Rails version 5.0.x and it lives on branch 50-stable.
1920
Version **51.x** supports Rails version 5.1.x and is currently on master until
@@ -32,6 +33,7 @@ adapters are available:
3233
- MySQL (`activerecord-jdbcmysql-adapter`)
3334
- PostgreSQL (`activerecord-jdbcpostgresql-adapter`)
3435
- SQLite3 (`activerecord-jdbcsqlite3-adapter`)
36+
- MSSQL (`activerecord-jdbcsqlserver-adapter`)
3537

3638
2. If you're generating a new Rails application, use the following command:
3739

@@ -166,4 +168,4 @@ license the database's drivers are licensed. See each driver gem's LICENSE.txt.
166168
[5]: https://github.com/jruby/activerecord-jdbc-adapter/wiki
167169
[6]: https://webchat.freenode.net/?channels=#jruby
168170
[7]: http://badge.fury.io/rb/activerecord-jdbc-adapter
169-
[8]: https://github.com/jruby/activerecord-jdbc-adapter/wiki/Migrating-from-1.2.x-to-1.3.0
171+
[8]: https://github.com/jruby/activerecord-jdbcsqlserver-adapter

lib/active_record/connection_adapters/mssql_adapter.rb

-1
This file was deleted.

lib/active_record/connection_adapters/sqlserver_adapter.rb

-1
This file was deleted.

lib/arjdbc/abstract/core.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def initialize(connection, logger = nil, config = {})
2222

2323
connection.configure_connection # will call us (maybe)
2424
end
25-
25+
2626
# Retrieve the raw `java.sql.Connection` object.
2727
# The unwrap parameter is useful if an attempt to unwrap a pooled (JNDI)
2828
# connection should be made - to really return the 'native' JDBC object.
@@ -54,7 +54,7 @@ def translate_exception(e, message)
5454
case e
5555
when SystemExit, SignalException, NoMemoryError then e
5656
when ActiveModel::RangeError, TypeError, RuntimeError then e
57-
else ActiveRecord::StatementInvalid.new(message)
57+
else super
5858
end
5959
end
6060

lib/arjdbc/jdbc.rb

-4
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,8 @@
22

33
module ArJdbc
44

5-
# @private
6-
AR40 = ::ActiveRecord::VERSION::MAJOR > 3
75
# @private
86
AR42 = ::ActiveRecord::VERSION::STRING >= '4.2'
9-
# @private
10-
AR50 = ::ActiveRecord::VERSION::MAJOR > 4
117

128
class << self
139

lib/arjdbc/jdbc/column.rb

+5-11
Original file line numberDiff line numberDiff line change
@@ -26,23 +26,17 @@ def initialize(config, name, *args)
2626
end
2727
end
2828

29-
if ArJdbc::AR50
30-
default = args[0].cast(default)
29+
default = args[0].cast(default)
3130

32-
sql_type = args.delete_at(1)
33-
type = args.delete_at(0)
31+
sql_type = args.delete_at(1)
32+
type = args.delete_at(0)
3433

35-
args.unshift(SqlTypeMetadata.new(:sql_type => sql_type, :type => type))
36-
elsif ArJdbc::AR42
37-
default = args[0].type_cast_from_database(default)
38-
else
39-
default = default_value(default)
40-
end
34+
args.unshift(SqlTypeMetadata.new(:sql_type => sql_type, :type => type))
4135

4236
# super <= 4.1: (name, default, sql_type = nil, null = true)
4337
# super >= 4.2: (name, default, cast_type, sql_type = nil, null = true)
4438
# super >= 5.0: (name, default, sql_type_metadata = nil, null = true)
45-
39+
4640
super(name, default, *args)
4741
init_column(name, default, *args)
4842
end

lib/arjdbc/mssql.rb

-7
This file was deleted.

0 commit comments

Comments
 (0)