activerecord-jdbc-adapter 52.4-java → 52.8-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: 7ef0f50586bac5757fd73503a4bbef0cca8dffe6611e490ce9e96f8762bee222
4
- data.tar.gz: 65f0feb78bd45194736ba1855584553b4a70dee3e0484b48dc926beadbe57797
3
+ metadata.gz: 3fcd23bc0bc83be277637d917d014b73f88f47f8131f6e3da8133438a2061c5b
4
+ data.tar.gz: 969acebe81158341aa35d20c4825f990ac4d0c2ee802f813ef82d4f2c0e645c3
5
5
  SHA512:
6
- metadata.gz: ab6db0ce815b95b89b0b522c0691b6af891463ffbe69f479d09135dee85ae9801993a9aed1440504644909589436593761c1358205aba34df725e377c737ec94
7
- data.tar.gz: f557a9c315b0dbd425598589db0bf2ea90e27d73bebd265344a51cbdf3e6ce1fa291e8a6593ffe82b409f9eb64aff6499dc5ef37619c637e4babfa6dc4d1b31c
6
+ metadata.gz: 6bca062cfc904fb675cbf6d20fc92c09d5824010d4d72dae1f57d86b2c7bc14fcf18b197eebfdecf6c53617c7a4e39e79a2ce00a6be2cd59b5407ab9a1e67301
7
+ data.tar.gz: ebf78548344f64fe6a853c6d94ea8a2cdafe32915e8cb140a0a05dfffade36acfae932f4835fca49e16052988c49002f388d53dc37093ed1acc1751599001d7a
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
@@ -30,4 +31,4 @@ Gemfile.lock
30
31
  .idea
31
32
  .settings
32
33
  activerecord-jdbc.iml
33
- lib/arjdbc/jdbc/adapter_java.jar
34
+ lib/arjdbc/jdbc/adapter_java.jar
@@ -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
@@ -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 = '52.4'
2
+ VERSION = '52.8'
3
3
  end
@@ -1,6 +1,6 @@
1
1
  namespace :'tomcat-jndi' do # contains a FS JNDI impl (for tests)
2
2
 
3
- TOMCAT_MAVEN_REPO = 'http://repo2.maven.org/maven2/org/apache/tomcat'
3
+ TOMCAT_MAVEN_REPO = 'https://repo1.maven.org/maven2/org/apache/tomcat'
4
4
  TOMCAT_VERSION = '7.0.54'
5
5
 
6
6
  DOWNLOAD_DIR = File.expand_path('../test/jars', File.dirname(__FILE__))
@@ -48,4 +48,4 @@ namespace :'tomcat-jndi' do # contains a FS JNDI impl (for tests)
48
48
  rm jar_path if File.exist?(jar_path)
49
49
  end
50
50
 
51
- end
51
+ end
data/rakelib/rails.rake CHANGED
@@ -51,7 +51,7 @@ namespace :rails do
51
51
  ruby_opts_string += " -C \"#{ar_path}\""
52
52
  ruby_opts_string += " -rbundler/setup"
53
53
  ruby_opts_string += " -rminitest -rminitest/excludes" unless ENV['NO_EXCLUDES'].eql?('true')
54
- file_list = ENV["TEST"] ? FileList[ ENV["TEST"] ] : test_files_finder.call
54
+ file_list = ENV["TEST"] ? FileList[ ENV["TEST"].split(',') ] : test_files_finder.call
55
55
  file_list_string = file_list.map { |fn| "\"#{fn}\"" }.join(' ')
56
56
  # test_loader_code = "-e \"ARGV.each{|f| require f}\"" # :direct
57
57
  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
@@ -2305,7 +2348,7 @@ public class RubyJdbcConnection extends RubyObject {
2305
2348
  return RubyString.newString(runtime, DateTimeUtils.dateToString(value));
2306
2349
  }
2307
2350
 
2308
- return DateTimeUtils.newDateAsTime(context, value, null).callMethod(context, "to_date");
2351
+ return DateTimeUtils.newDateAsTime(context, value, DateTimeZone.UTC).callMethod(context, "to_date");
2309
2352
  }
2310
2353
 
2311
2354
  protected IRubyObject timeToRuby(final ThreadContext context,
@@ -200,6 +200,57 @@ public class MSSQLRubyJdbcConnection extends RubyJdbcConnection {
200
200
  });
201
201
  }
202
202
 
203
+ /**
204
+ * Executes an INSERT SQL statement
205
+ * @param context
206
+ * @param sql
207
+ * @param pk Rails PK
208
+ * @return ActiveRecord::Result
209
+ * @throws SQLException
210
+ */
211
+ @Override
212
+ @JRubyMethod(name = "execute_insert_pk", required = 2)
213
+ public IRubyObject execute_insert_pk(final ThreadContext context, final IRubyObject sql, final IRubyObject pk) {
214
+
215
+ // MSSQL does not like composite primary keys here so chop it if there is more than one column
216
+ IRubyObject modifiedPk = pk;
217
+
218
+ if (pk instanceof RubyArray) {
219
+ RubyArray ary = (RubyArray) pk;
220
+ if (ary.size() > 0) {
221
+ modifiedPk = ary.eltInternal(0);
222
+ }
223
+ }
224
+
225
+ return super.execute_insert_pk(context, sql, modifiedPk);
226
+ }
227
+
228
+ /**
229
+ * Executes an INSERT SQL statement using a prepared statement
230
+ * @param context
231
+ * @param sql
232
+ * @param binds RubyArray of values to be bound to the query
233
+ * @param pk Rails PK
234
+ * @return ActiveRecord::Result
235
+ * @throws SQLException
236
+ */
237
+ @Override
238
+ @JRubyMethod(name = "execute_insert_pk", required = 3)
239
+ public IRubyObject execute_insert_pk(final ThreadContext context, final IRubyObject sql, final IRubyObject binds,
240
+ final IRubyObject pk) {
241
+ // MSSQL does not like composite primary keys here so chop it if there is more than one column
242
+ IRubyObject modifiedPk = pk;
243
+
244
+ if (pk instanceof RubyArray) {
245
+ RubyArray ary = (RubyArray) pk;
246
+ if (ary.size() > 0) {
247
+ modifiedPk = ary.eltInternal(0);
248
+ }
249
+ }
250
+
251
+ return super.execute_insert_pk(context, sql, binds, modifiedPk);
252
+ }
253
+
203
254
  @Override
204
255
  protected Integer jdbcTypeFor(final String type) {
205
256
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-jdbc-adapter
3
3
  version: !ruby/object:Gem::Version
4
- version: '52.4'
4
+ version: '52.8'
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-01 00:00:00.000000000 Z
11
+ date: 2021-07-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -233,8 +233,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
233
233
  - !ruby/object:Gem::Version
234
234
  version: '0'
235
235
  requirements: []
236
- rubyforge_project:
237
- rubygems_version: 2.7.10
236
+ rubygems_version: 3.2.14
238
237
  signing_key:
239
238
  specification_version: 4
240
239
  summary: JDBC adapter for ActiveRecord, for use within JRuby on Rails.