activerecord-jdbc-adapter 50.5-java → 50.6-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: c4366763684412c337ad138f87ebc65f8da2d6fdaf34f4c8241eadefdb124376
4
- data.tar.gz: bae02c5c8a94999cdc54dd5b570fb189b30835cbea0f5acffa2821904fed7336
3
+ metadata.gz: b82900720a11af00dfa68a565654799df71b7ec9b99a95ba16d6ae1f09866133
4
+ data.tar.gz: 3256dba37920bee8ba5e6c5c962a991f5b02faca40c0a5f57aca0767dec6c928
5
5
  SHA512:
6
- metadata.gz: 58b61ac6c9a05c6b3a573e4c566491b61d3855f1f1285f357dc2bfc43e1db236c4224412d68afcfabc61f0cf4af71c6d56fa2b8f9cece6c7b92711cafbbeb3da
7
- data.tar.gz: 110de6454bcc56300fdef4d67fa449694ca78f448a211fa54f4d71711080e544be3384512fb04ad1ce383d30806f036a2c9ae188b6bd2d2a87d178753d010974
6
+ metadata.gz: 1f8637a8be04082875d4f072d5b0abd154f319f750aa48ea54b2c8b9a5864243489a317d1b276197406e8e9afa4095d7e9ad1cc684fb171c736006280d2807ce
7
+ data.tar.gz: bad2b3a3bbe0ff7001339967f5f1a1db7cc81abb2211d6cdb4aa1d65bd0f55fd08eda746ddb2298b0c21e3d18f6b0be2831fb5b6179852fc73f562fb228f8f1a
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 = '50.5'
2
+ VERSION = '50.6'
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: '50.5'
4
+ version: '50.6'
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