activerecord-jdbc-alt-adapter 50.5.0-java → 50.6.1-java

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e9379d10ca13be5bdfe6b2d9e08f1f0bb90c12b4a87a11a2dbe4122742bd0fd4
4
- data.tar.gz: 6fbff250cd49c44410829511184f0ef69e4d4aff5b6045da2b4a0d4421dd1387
3
+ metadata.gz: 6eee53bae892f228677fb5abcf5548fd9957731deade33f82446d70af7766365
4
+ data.tar.gz: cb8386a343a16d9a503eccac19261a5ce975b94613d79ab0d8dbfeee87f0b955
5
5
  SHA512:
6
- metadata.gz: 69e281f1bdb34d112fca0a78193999b2c8b72e36006e5ac28a11de998f594a314baa156337359fa98b85d8055072a23f1ac1c867a672ffb4b305059332c6e3fa
7
- data.tar.gz: 2c104450a45f8f84cf740b10ce079fa55e815300ceebcb8d22de91a44e8e33f1758907891e41738b3c9e73289300e3210bd49b7b7032b9de6ad5765ec8d12f17
6
+ metadata.gz: 36e77bf1b8f5795bda11f614f5e84743ab34f6ef9a802a28d7ca621727dca92987961e867011fc0ba51905e4a5158b89bb46670d265896d633114f0cc27d3fb3
7
+ data.tar.gz: c57e1fcf4b860f9f6466fbd7e2cfb7c4d34a5ce5b50bc647fdd4279d950c6aa41ffefa975a82269f20ab60be07a5a1f9ce64c95f75d420747ac3b3e8903828d9
data/.gitignore CHANGED
@@ -2,6 +2,7 @@
2
2
  *.tgz
3
3
  *~
4
4
  *.log
5
+ /log/
5
6
  patches*
6
7
  *#
7
8
  TAGS
data/Gemfile CHANGED
@@ -49,7 +49,7 @@ group :test do
49
49
 
50
50
  gem 'bcrypt', '~> 3.1.11', require: false
51
51
  gem 'builder', require: false
52
- gem 'jdbc-mssql', '~> 0.6.0', require: nil
52
+ gem 'jdbc-mssql', '~> 0.7.0', require: nil
53
53
  end
54
54
 
55
55
  group :rails do
@@ -13,10 +13,10 @@ module ArJdbc
13
13
  binds = convert_legacy_binds_to_attributes(binds) if binds.first.is_a?(Array)
14
14
 
15
15
  if without_prepared_statement?(binds)
16
- log(sql, name) { @connection.execute_insert(sql) }
16
+ log(sql, name) { @connection.execute_insert_pk(sql, pk) }
17
17
  else
18
18
  log(sql, name, binds) do
19
- @connection.execute_insert(sql, binds)
19
+ @connection.execute_insert_pk(sql, binds, pk)
20
20
  end
21
21
  end
22
22
  end
Binary file
@@ -134,6 +134,13 @@ module ActiveRecord
134
134
  super
135
135
  end
136
136
 
137
+ def reset!
138
+ # execute 'IF @@TRANCOUNT > 0 ROLLBACK TRANSACTION'
139
+ # NOTE: it seems the above line interferes with the jdbc driver
140
+ # and ending up in connection closed, issue seen in rails 5.2 and 6.0
141
+ reconnect!
142
+ end
143
+
137
144
  def disable_referential_integrity
138
145
  tables = tables_with_referential_integrity
139
146
 
@@ -52,6 +52,8 @@ ArJdbc::ConnectionMethods.module_eval do
52
52
 
53
53
  # @note Assumes SQLServer SQL-JDBC driver on the class-path.
54
54
  def sqlserver_connection(config)
55
+ config = config.deep_dup
56
+
55
57
  config[:adapter_spec] ||= ::ArJdbc::MSSQL
56
58
  config[:adapter_class] = ActiveRecord::ConnectionAdapters::MSSQLAdapter unless config.key?(:adapter_class)
57
59
 
@@ -87,7 +87,7 @@ module ActiveRecord
87
87
  end
88
88
 
89
89
  def identity_column_name(table_name)
90
- for column in columns(table_name)
90
+ for column in schema_cache.columns(table_name)
91
91
  return column.name if column.identity?
92
92
  end
93
93
  nil
@@ -57,7 +57,7 @@ module ActiveRecord
57
57
  # NOTE: This is ready, all implemented in the java part of adapter,
58
58
  # it uses MSSQLColumn, SqlTypeMetadata, etc.
59
59
  def columns(table_name)
60
- @connection.columns(table_name)
60
+ log('JDBC: GETCOLUMNS', 'SCHEMA') { @connection.columns(table_name) }
61
61
  rescue => e
62
62
  raise translate_exception_class(e, nil)
63
63
  end
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
  ArJdbc::ConnectionMethods.module_eval do
3
3
  def mysql_connection(config)
4
+ config = config.deep_dup
4
5
  # NOTE: this isn't "really" necessary but Rails (in tests) assumes being able to :
5
6
  # ActiveRecord::Base.mysql2_connection ActiveRecord::Base.configurations['arunit'].merge(database: ...)
6
7
  config = symbolize_keys_if_necessary(config)
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
  ArJdbc::ConnectionMethods.module_eval do
3
3
  def postgresql_connection(config)
4
+ config = config.deep_dup
4
5
  # NOTE: this isn't "really" necessary but Rails (in tests) assumes being able to :
5
6
  # ActiveRecord::Base.postgresql_connection ActiveRecord::Base.configurations['arunit'].merge(:insert_returning => false)
6
7
  # ... while using symbols by default but than configurations returning string keys ;(
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
  ArJdbc::ConnectionMethods.module_eval do
3
3
  def sqlite3_connection(config)
4
+ config = config.deep_dup
4
5
  config[:adapter_spec] ||= ::ArJdbc::SQLite3
5
6
  config[:adapter_class] = ActiveRecord::ConnectionAdapters::SQLite3Adapter unless config.key?(:adapter_class)
6
7
 
@@ -1,3 +1,3 @@
1
1
  module ArJdbc
2
- VERSION = '50.5.0'
2
+ VERSION = '50.6.1'
3
3
  end
data/rakelib/rails.rake CHANGED
@@ -57,7 +57,7 @@ namespace :rails do
57
57
  ruby_opts_string += " -C \"#{ar_path}\""
58
58
  ruby_opts_string += " -rbundler/setup"
59
59
  ruby_opts_string += " -rminitest -rminitest/excludes" unless ENV['NO_EXCLUDES'].eql?('true')
60
- file_list = ENV["TEST"] ? FileList[ ENV["TEST"] ] : test_files_finder.call
60
+ file_list = ENV["TEST"] ? FileList[ ENV["TEST"].split(',') ] : test_files_finder.call
61
61
  file_list_string = file_list.map { |fn| "\"#{fn}\"" }.join(' ')
62
62
  # test_loader_code = "-e \"ARGV.each{|f| require f}\"" # :direct
63
63
  option_list = ( ENV["TESTOPTS"] || ENV["TESTOPT"] || ENV["TEST_OPTS"] || '' )
@@ -727,7 +727,10 @@ public class RubyJdbcConnection extends RubyObject {
727
727
 
728
728
  private void connectImpl(final boolean forceConnection) throws SQLException {
729
729
  setConnection( forceConnection ? newConnection() : null );
730
- if ( forceConnection ) configureConnection();
730
+ if (forceConnection) {
731
+ if (getConnectionImpl() == null) throw new SQLException("Didn't get a connection. Wrong URL?");
732
+ configureConnection();
733
+ }
731
734
  }
732
735
 
733
736
  @JRubyMethod(name = "read_only?")
@@ -885,15 +888,31 @@ public class RubyJdbcConnection extends RubyObject {
885
888
  return mapQueryResult(context, connection, resultSet);
886
889
  }
887
890
 
891
+ private static String[] createStatementPk(IRubyObject pk) {
892
+ String[] statementPk;
893
+ if (pk instanceof RubyArray) {
894
+ RubyArray ary = (RubyArray) pk;
895
+ int size = ary.size();
896
+ statementPk = new String[size];
897
+ for (int i = 0; i < size; i++) {
898
+ statementPk[i] = sqlString(ary.eltInternal(i));
899
+ }
900
+ } else {
901
+ statementPk = new String[] { sqlString(pk) };
902
+ }
903
+ return statementPk;
904
+ }
905
+
888
906
  /**
889
907
  * Executes an INSERT SQL statement
890
908
  * @param context
891
909
  * @param sql
910
+ * @param pk Rails PK
892
911
  * @return ActiveRecord::Result
893
912
  * @throws SQLException
894
913
  */
895
- @JRubyMethod(name = "execute_insert", required = 1)
896
- public IRubyObject execute_insert(final ThreadContext context, final IRubyObject sql) {
914
+ @JRubyMethod(name = "execute_insert_pk", required = 2)
915
+ public IRubyObject execute_insert_pk(final ThreadContext context, final IRubyObject sql, final IRubyObject pk) {
897
916
  return withConnection(context, new Callable<IRubyObject>() {
898
917
  public IRubyObject call(final Connection connection) throws SQLException {
899
918
  Statement statement = null;
@@ -901,7 +920,13 @@ public class RubyJdbcConnection extends RubyObject {
901
920
  try {
902
921
 
903
922
  statement = createStatement(context, connection);
904
- statement.executeUpdate(query, Statement.RETURN_GENERATED_KEYS);
923
+
924
+ if (pk == context.nil || pk == context.fals || !supportsGeneratedKeys(connection)) {
925
+ statement.executeUpdate(query, Statement.RETURN_GENERATED_KEYS);
926
+ } else {
927
+ statement.executeUpdate(query, createStatementPk(pk));
928
+ }
929
+
905
930
  return mapGeneratedKeys(context, connection, statement);
906
931
 
907
932
  } catch (final SQLException e) {
@@ -914,23 +939,35 @@ public class RubyJdbcConnection extends RubyObject {
914
939
  });
915
940
  }
916
941
 
942
+ @Deprecated
943
+ @JRubyMethod(name = "execute_insert", required = 1)
944
+ public IRubyObject execute_insert(final ThreadContext context, final IRubyObject sql) {
945
+ return execute_insert_pk(context, sql, context.nil);
946
+ }
947
+
917
948
  /**
918
949
  * Executes an INSERT SQL statement using a prepared statement
919
950
  * @param context
920
951
  * @param sql
921
952
  * @param binds RubyArray of values to be bound to the query
953
+ * @param pk Rails PK
922
954
  * @return ActiveRecord::Result
923
955
  * @throws SQLException
924
956
  */
925
- @JRubyMethod(name = "execute_insert", required = 2)
926
- public IRubyObject execute_insert(final ThreadContext context, final IRubyObject sql, final IRubyObject binds) {
957
+ @JRubyMethod(name = "execute_insert_pk", required = 3)
958
+ public IRubyObject execute_insert_pk(final ThreadContext context, final IRubyObject sql, final IRubyObject binds,
959
+ final IRubyObject pk) {
927
960
  return withConnection(context, new Callable<IRubyObject>() {
928
961
  public IRubyObject call(final Connection connection) throws SQLException {
929
962
  PreparedStatement statement = null;
930
963
  final String query = sqlString(sql);
931
964
  try {
965
+ if (pk == context.nil || pk == context.fals || !supportsGeneratedKeys(connection)) {
966
+ statement = connection.prepareStatement(query, Statement.RETURN_GENERATED_KEYS);
967
+ } else {
968
+ statement = connection.prepareStatement(query, createStatementPk(pk));
969
+ }
932
970
 
933
- statement = connection.prepareStatement(query, Statement.RETURN_GENERATED_KEYS);
934
971
  setStatementParameters(context, connection, statement, (RubyArray) binds);
935
972
  statement.executeUpdate();
936
973
  return mapGeneratedKeys(context, connection, statement);
@@ -945,6 +982,12 @@ public class RubyJdbcConnection extends RubyObject {
945
982
  });
946
983
  }
947
984
 
985
+ @Deprecated
986
+ @JRubyMethod(name = "execute_insert", required = 2)
987
+ public IRubyObject execute_insert(final ThreadContext context, final IRubyObject binds, final IRubyObject sql) {
988
+ return execute_insert_pk(context, sql, binds, context.nil);
989
+ }
990
+
948
991
  /**
949
992
  * Executes an UPDATE (DELETE) SQL statement
950
993
  * @param context
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-jdbc-alt-adapter
3
3
  version: !ruby/object:Gem::Version
4
- version: 50.5.0
4
+ version: 50.6.1
5
5
  platform: java
6
6
  authors:
7
7
  - Nick Sieger, Ola Bini, Karol Bucek and JRuby contributors
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-11-24 00:00:00.000000000 Z
11
+ date: 2019-12-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -263,7 +263,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
263
263
  version: '0'
264
264
  requirements: []
265
265
  rubyforge_project:
266
- rubygems_version: 2.7.10
266
+ rubygems_version: 2.7.6
267
267
  signing_key:
268
268
  specification_version: 4
269
269
  summary: ActiveRecord JDBC adapter, for use within JRuby on Rails and SQL Server