Skip to content

Commit 4a79ed3

Browse files
committed
Merge branch '50-stable' into 51-stable
* 50-stable: [refactor] we could do a faster-path Date.new [refactor] move Date.new helper to utils mention and link SQLServer adapter fork [postgres] allow legacy binds [postgres] sync extract_value_from_default with AR Added a bit to the readme about mssql support Remove MSSQL support from rake tasks Fix more tests for supporting mssql Remove the mssql files (other than Java source related) and revert the mssql gemspec back to its original form Getting more of my changes in for activerecord-sqlserver-adapter gem support Rearranged the code so that we reuse the SQLServerAdapter class so more of the activerecord-sqlserver-adapter gem's methods will work Initial overrides to work with the activerecord-sqlserver-adapter gem to support MSSQL on Rails 5.0 Removed some rails version variables that are no longer needed
2 parents b30cba6 + 2db2937 commit 4a79ed3

23 files changed

+317
-1979
lines changed

README.md

Lines changed: 11 additions & 9 deletions
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

Lines changed: 0 additions & 1 deletion
This file was deleted.

lib/active_record/connection_adapters/sqlserver_adapter.rb

Lines changed: 0 additions & 1 deletion
This file was deleted.

lib/arjdbc/abstract/core.rb

Lines changed: 2 additions & 2 deletions
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.
@@ -56,7 +56,7 @@ def translate_exception(e, message)
5656
case e
5757
when SystemExit, SignalException, NoMemoryError then e
5858
when ActiveModel::RangeError, TypeError, RuntimeError then e
59-
else ActiveRecord::StatementInvalid.new(message)
59+
else super
6060
end
6161
end
6262

lib/arjdbc/abstract/database_statements.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ module DatabaseStatements
1010
NO_BINDS = [].freeze
1111

1212
def exec_insert(sql, name = nil, binds = NO_BINDS, pk = nil, sequence_name = nil)
13+
binds = convert_legacy_binds_to_attributes(binds) if binds.first.is_a?(Array)
14+
1315
if without_prepared_statement?(binds)
1416
log(sql, name) { @connection.execute_insert(sql) }
1517
else
@@ -22,6 +24,8 @@ def exec_insert(sql, name = nil, binds = NO_BINDS, pk = nil, sequence_name = nil
2224
# It appears that at this point (AR 5.0) "prepare" should only ever be true
2325
# if prepared statements are enabled
2426
def exec_query(sql, name = nil, binds = NO_BINDS, prepare: false)
27+
binds = convert_legacy_binds_to_attributes(binds) if binds.first.is_a?(Array)
28+
2529
if without_prepared_statement?(binds)
2630
log(sql, name) { @connection.execute_query(sql) }
2731
else
@@ -34,6 +38,8 @@ def exec_query(sql, name = nil, binds = NO_BINDS, prepare: false)
3438
end
3539

3640
def exec_update(sql, name = nil, binds = NO_BINDS)
41+
binds = convert_legacy_binds_to_attributes(binds) if binds.first.is_a?(Array)
42+
3743
if without_prepared_statement?(binds)
3844
log(sql, name) { @connection.execute_update(sql) }
3945
else

lib/arjdbc/jdbc.rb

Lines changed: 0 additions & 4 deletions
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

Lines changed: 5 additions & 11 deletions
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

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)