activerecord-jdbc-adapter 52.4-java → 52.5-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: d8e70e0571c6ded05ed8c9240d50a5176ac7a298442bd1ec94ef38eb943a2796
4
+ data.tar.gz: 43c36c000d0df5e09df5b809109c2bed92e72387a3a85d459d420b39f4fe05a7
5
5
  SHA512:
6
- metadata.gz: ab6db0ce815b95b89b0b522c0691b6af891463ffbe69f479d09135dee85ae9801993a9aed1440504644909589436593761c1358205aba34df725e377c737ec94
7
- data.tar.gz: f557a9c315b0dbd425598589db0bf2ea90e27d73bebd265344a51cbdf3e6ce1fa291e8a6593ffe82b409f9eb64aff6499dc5ef37619c637e4babfa6dc4d1b31c
6
+ metadata.gz: b351eb3ea0db7836b3c77b8e897591fbc3b95f41286342624b36bcf1dd5c00f0b8f8188383ee0485580dd4427bc748b1590c983a2d5b4e49874c4210673c43d7
7
+ data.tar.gz: 6da391f22f9fa4724d435dcc695191d8f0cf920e59317ed0fdb20f349dd7a0daba6627138ebf0e402bf3ef1a52b777637dc01ca12ea46fb9906bd795199b4ff3
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
@@ -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.5'
3
3
  end
@@ -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
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.5'
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: 2019-12-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement