Skip to content
Open
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
64021ef
Revert "Add Rails 8.1 compatibility"
brykgroup-andrews Jun 30, 2026
49a13bc
Pin rdoc to ~> 7 to fix JRuby native compilation issues
brykgroup-andrews May 4, 2026
dab401b
Disable ReaperTest::test_reaper_works_after_pool_discard in JDBC due …
brykgroup-andrews May 22, 2026
b6a1bc3
Disable broken :test_url_invalid_adapter due to added sqlserver adapter
brykgroup-andrews Jun 17, 2026
a3a866f
Force numeric/boolean to be encoded as varchar to mirror behaviour of…
brykgroup-andrews May 5, 2026
0131de7
Migrate client_min_messages in Postgres to use newer APIs
brykgroup-andrews May 8, 2026
c687b0c
Postgres now respects decode_dates setting
brykgroup-andrews May 8, 2026
376e562
Fix Postgres disable_extension to work the same way enable_extenion w…
brykgroup-andrews May 11, 2026
dfd7620
Added fixednum lookup to Postgres columns for columnTypeMap to allow …
brykgroup-andrews May 11, 2026
246a640
Monkey patch to allow time value parsing to fall through fallback_str…
brykgroup-andrews May 11, 2026
84ca553
Fix postgres not returning a result object for raw queries
brykgroup-andrews May 11, 2026
dc722cc
Generalized timestamp infinity checking to support BigDecimal + other…
brykgroup-andrews May 13, 2026
2b7118d
Update PostgreSQL::rename_enum to match rails implementation
brykgroup-andrews May 14, 2026
7c62084
Update PostgreSQL::add_enum_value to match rails implementation
brykgroup-andrews May 14, 2026
6a4a88f
Use ruby-side type casting in array params for correct range literal …
brykgroup-andrews May 14, 2026
3a3e045
Fix dirty tracking when loading HStore from Postgres
brykgroup-andrews May 14, 2026
0286957
Carry over set_constraints from rails Postgres driver
brykgroup-andrews May 14, 2026
9929c0a
Match default PG gem stringtype connection param
brykgroup-andrews May 20, 2026
eb8975b
Implement raw_exec_query to fix AsyncHasManyAssociationsTest#test_asy…
brykgroup-andrews May 20, 2026
d4a6b20
Migrate query logging to match upstream ruby call style and signatures
brykgroup-andrews May 21, 2026
974f9d4
Switch to base rails preprocess_query call, remove now-redundant :che…
brykgroup-andrews May 23, 2026
e9fe057
Properly handle returning: kwarg in exec_insert
brykgroup-andrews May 23, 2026
84b926e
Properly handle raw SQL for upserts
brykgroup-andrews May 26, 2026
58068df
Remove outdated and unneeded override of extract_table_ref_from_inser…
brykgroup-andrews May 27, 2026
924b346
Remove outdated and unneeded override of default_sequence_name from P…
brykgroup-andrews May 27, 2026
95d6cd6
Added default timezone to time/timestamp OID types
brykgroup-andrews May 27, 2026
0eda888
Add JVM-compatible test_preserving_time_objects_with_local_time_conve…
brykgroup-andrews May 27, 2026
fda88d0
Exclude PessimisticLockingTest#test_with_lock_locks_with_no_args due …
brykgroup-andrews Jun 1, 2026
ccde2eb
Handle Rails 8.0 removed Numeric#toTime
brykgroup-andrews Jun 1, 2026
5bfebe0
Exclude broken msgpack-jruby tests
brykgroup-andrews Jun 1, 2026
cb595b7
Insert json as type OTHER to allow for coersion to column type
brykgroup-andrews Jun 2, 2026
1831186
Properly set timezone when setting timestamp params
brykgroup-andrews Jun 2, 2026
c672e9f
Disabled marshalling tests that are broken with AR format 6.1 + JRuby…
brykgroup-andrews Jun 2, 2026
9accad2
Monkeypatch to work around bug in prism logger polyfill breaking tests
brykgroup-andrews Jun 5, 2026
7e6d672
Synchronize ActiveSupport callback registration in tests to compensat…
brykgroup-andrews Jun 5, 2026
bbeafdc
Add support for PG bind-param hash in blob params
brykgroup-andrews Jun 17, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -105,5 +105,6 @@ group :rails do
gem 'minitest-rg', require: nil
gem 'minitest-rails', require: nil
gem 'benchmark-ips', require: nil
gem 'rdoc', '~> 7', require: false

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be temporary; we need to work with rbs folks to get a release out with JRuby support.

end
end
2 changes: 1 addition & 1 deletion activerecord-jdbc-adapter.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Gem::Specification.new do |gem|
gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) }
gem.test_files = gem.files.grep(%r{^test/})

gem.add_dependency "activerecord", "~> 8.0"
gem.add_dependency "activerecord", "~> 8.0.0"

#gem.add_development_dependency 'test-unit', '2.5.4'
#gem.add_development_dependency 'test-unit-context', '>= 0.3.0'
Expand Down
15 changes: 0 additions & 15 deletions lib/arjdbc/abstract/database_statements.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,6 @@ module DatabaseStatements

NO_BINDS = [].freeze

unless method_defined?(:mark_transaction_written_if_write)
def mark_transaction_written_if_write(sql)
if write_query?(sql)
ensure_writes_are_allowed(sql)
mark_transaction_written
end
end
end

unless method_defined?(:check_if_write_query)
def check_if_write_query(sql)
ensure_writes_are_allowed(sql) if write_query?(sql)
end
end

def exec_insert(sql, name = nil, binds = NO_BINDS, pk = nil, sequence_name = nil, returning: nil)
if preventing_writes?
raise ActiveRecord::ReadOnlyError, "Write query attempted while in readonly mode: #{sql}"
Expand Down
25 changes: 25 additions & 0 deletions lib/arjdbc/abstract/time_value_jruby_compat_monkey_patch.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# frozen_string_literal: true

require "active_model/type/helpers/time_value"

# The caller only handles ArgumentError as a failure,
# but JRuby raises TypeError for invalid formats in Time.new() (non-standard),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to have a JRuby bug reference here so we can revert this patch when JRuby gets fixed.

# which isn't handled by the caller.
# We just return nil here as it will result in fallback parsing, same as raising.
module ActiveModel
module Type
module Helpers
module TimeValue
module JRubyCompat
private
def fast_string_to_time(string)
super
rescue TypeError
nil
end
end
prepend JRubyCompat
end
end
end
end
7 changes: 5 additions & 2 deletions lib/arjdbc/postgresql/adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
require 'active_model'

require "arjdbc/abstract/relation_query_attribute_monkey_patch"
require "arjdbc/abstract/time_value_jruby_compat_monkey_patch"

module ArJdbc
# Strives to provide Rails built-in PostgreSQL adapter (API) compatibility.
Expand Down Expand Up @@ -104,6 +105,8 @@ def configure_connection
end
end

@raw_connection.decode_dates = decode_dates # Copy to java land for performance

reload_type_map
end

Expand Down Expand Up @@ -325,6 +328,7 @@ def enable_extension(name, **)
# Set to +:cascade+ to drop dependent objects as well.
# Defaults to false.
def disable_extension(name, force: false)
_schema, name = name.to_s.split(".").values_at(-2, -1)
internal_exec_query("DROP EXTENSION IF EXISTS \"#{name}\"#{' CASCADE' if force == :cascade}").tap {
reload_type_map
}
Expand Down Expand Up @@ -596,8 +600,7 @@ def all_schemas
# Returns the current client message level.
def client_min_messages
return nil if redshift? # not supported on Redshift
# Need to use #execute so we don't try to access the type map before it is initialized
execute('SHOW client_min_messages', 'SCHEMA').values.first.first
query_value("SHOW client_min_messages", "SCHEMA")
end

# Set the client message level.
Expand Down
17 changes: 0 additions & 17 deletions lib/arjdbc/postgresql/schema_statements.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,6 @@ module SchemaStatements
ForeignKeyDefinition = ActiveRecord::ConnectionAdapters::ForeignKeyDefinition
Utils = ActiveRecord::ConnectionAdapters::PostgreSQL::Utils

def decode_string_array(value)
return value if value.is_a?(Array)
_arjdbc_array_parser.parse_pg_array(value)
end

private

def _arjdbc_array_parser
@_arjdbc_array_parser ||= begin
obj = Object.new
obj.extend(ActiveRecord::ConnectionAdapters::PostgreSQL::ArrayParser)
obj
end
end

public

def foreign_keys(table_name)
scope = quoted_scope(table_name)
fk_info = internal_exec_query(<<~SQL, "SCHEMA", allow_retry: true, materialize_transactions: false)
Expand Down
5 changes: 4 additions & 1 deletion src/java/arjdbc/postgresql/PostgreSQLResult.java
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,10 @@ protected IRubyObject columnTypeMap(final ThreadContext context) throws SQLExcep
runtime.newFixnum(mod),
name);

if (!type.isNil()) types.fastASet(name, type);
if (!type.isNil()) {
types.fastASet(name, type);
types.fastASet(runtime.newFixnum(i), type);
}
}

return types;
Expand Down
20 changes: 20 additions & 0 deletions src/java/arjdbc/postgresql/PostgreSQLRubyJdbcConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ public class PostgreSQLRubyJdbcConnection extends arjdbc.jdbc.RubyJdbcConnection

private RubyClass resultClass;
private RubyHash typeMap = null;
private boolean decodeDates = false;

public PostgreSQLRubyJdbcConnection(Ruby runtime, RubyClass metaClass) {
super(runtime, metaClass);
Expand Down Expand Up @@ -148,6 +149,15 @@ protected String buildURL(final ThreadContext context, final IRubyObject url) {
return DriverWrapper.buildURL(url, Collections.EMPTY_MAP);
}

@Override
protected Integer jdbcTypeForPrimitiveAttribute(final ThreadContext context,
final IRubyObject attribute) throws SQLException {
if (attribute instanceof RubyNumeric || attribute instanceof RubyBoolean) {
return Types.VARCHAR;
}
return super.jdbcTypeForPrimitiveAttribute(context, attribute);
}

@Override
protected DriverWrapper newDriverWrapper(final ThreadContext context, final String driver) {
DriverWrapper driverWrapper = super.newDriverWrapper(context, driver);
Expand Down Expand Up @@ -804,6 +814,10 @@ protected IRubyObject dateToRuby(ThreadContext context, Ruby runtime, ResultSet
final String value = resultSet.getString(index);
if (value == null) return context.nil;

if (!decodeDates) {
return RubyString.newUnicodeString(runtime, value);
}

final int len = value.length();
if (len < 10 && value.charAt(len - 1) == 'y') { // infinity / -infinity
IRubyObject infinity = parseInfinity(context.runtime, value);
Expand Down Expand Up @@ -1084,4 +1098,10 @@ public IRubyObject typemap_set(ThreadContext context, IRubyObject mapArg) {
this.typeMap = (RubyHash) mapArg;
return mapArg;
}

@PG @JRubyMethod(name = "decode_dates=")
public IRubyObject setDecodeDates(ThreadContext context, IRubyObject value) {
this.decodeDates = value.isTrue();
return value;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
exclude :test_url_invalid_adapter, "sqlserver is not a built-in adapter, so rails complains when validating the error"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very annoying that the Rails tests implicitly require there be no other adapters. This warrants a patch to Rails imho.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
exclude :test_url_invalid_adapter, "sqlserver is not a built-in adapter, so rails complains when validating the error"
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
exclude :test_some_time, 'intermittent failures, leaks thread, fires at high frequency'
exclude :test_connection_pool_starts_reaper, 'intermittent failures, leaks thread, fires at high frequency'
exclude :test_reaper_works_after_pool_discard, 'deadlocks under JDBC due to high frequency discard'

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we know why this deadlocks? Of course we have lots of excludes but this seems like one we should try to fix rather than excluding.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
exclude :test_url_invalid_adapter, "sqlserver is not a built-in adapter, so rails complains when validating the error"
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
exclude :test_url_invalid_adapter, "sqlserver is not a built-in adapter, so rails complains when validating the error"