Skip to content

Commit

Permalink
Merge pull request #1164 from JesseChavez/more_rails_71_fixes
Browse files Browse the repository at this point in the history
jdbc-mysql gem fix and some AR postgres fixes
  • Loading branch information
enebo authored Nov 14, 2024
2 parents 0a959b8 + 28f4b0c commit c8c1a5b
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 17 deletions.
2 changes: 1 addition & 1 deletion jdbc-mysql/lib/jdbc/mysql.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module Jdbc
module MySQL

def self.driver_jar
"mysql-connector-java-#{DRIVER_VERSION}.jar"
"mysql-connector-j-#{DRIVER_VERSION}.jar"
end

def self.load_driver(method = :load)
Expand Down
16 changes: 3 additions & 13 deletions lib/arjdbc/abstract/database_statements.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,18 +78,6 @@ def exec_update(sql, name = 'SQL', binds = NO_BINDS)
end
alias :exec_delete :exec_update

def execute(sql, name = nil, async: false, allow_retry: false, materialize_transactions: true)
sql = transform_query(sql)

if preventing_writes? && write_query?(sql)
raise ActiveRecord::ReadOnlyError, "Write query attempted while in readonly mode: #{sql}"
end

mark_transaction_written_if_write(sql)

raw_execute(sql, name, async: async, allow_retry: allow_retry, materialize_transactions: materialize_transactions)
end

# overridden to support legacy binds
def select_all(arel, name = nil, binds = NO_BINDS, preparable: nil, async: false)
binds = convert_legacy_binds_to_attributes(binds) if binds.first.is_a?(Array)
Expand All @@ -107,7 +95,9 @@ def convert_legacy_binds_to_attributes(binds)
def raw_execute(sql, name, async: false, allow_retry: false, materialize_transactions: true)
log(sql, name, async: async) do
with_raw_connection(allow_retry: allow_retry, materialize_transactions: materialize_transactions) do |conn|
conn.execute(sql)
result = conn.execute(sql)
verified!
result
end
end
end
Expand Down
19 changes: 19 additions & 0 deletions lib/arjdbc/postgresql/adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -787,6 +787,25 @@ def jdbc_connection_class
def new_client(conn_params, adapter_instance)
jdbc_connection_class.new(conn_params, adapter_instance)
end

def dbconsole(config, options = {})
pg_config = config.configuration_hash

ENV["PGUSER"] = pg_config[:username] if pg_config[:username]
ENV["PGHOST"] = pg_config[:host] if pg_config[:host]
ENV["PGPORT"] = pg_config[:port].to_s if pg_config[:port]
ENV["PGPASSWORD"] = pg_config[:password].to_s if pg_config[:password] && options[:include_password]
ENV["PGSSLMODE"] = pg_config[:sslmode].to_s if pg_config[:sslmode]
ENV["PGSSLCERT"] = pg_config[:sslcert].to_s if pg_config[:sslcert]
ENV["PGSSLKEY"] = pg_config[:sslkey].to_s if pg_config[:sslkey]
ENV["PGSSLROOTCERT"] = pg_config[:sslrootcert].to_s if pg_config[:sslrootcert]
if pg_config[:variables]
ENV["PGOPTIONS"] = pg_config[:variables].filter_map do |name, value|
"-c #{name}=#{value.to_s.gsub(/[ \\]/, '\\\\\0')}" unless value == ":default" || value == :default
end.join(" ")
end
find_cmd_and_exec("psql", config.database)
end
end

def initialize(...)
Expand Down
3 changes: 0 additions & 3 deletions test/db/postgresql/table_name_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,6 @@ class SerialWithTrigger < ActiveRecord::Base
end

def test_serial_with_trigger
pend "Issue happens in active record 7.1 internals, issue wass logged in rails repo"
# issue link: https://github.com/rails/rails/issues/52485

sn = SerialWithTrigger.create!(value: 1_234_567_890.to_s)

assert sn.reload
Expand Down

0 comments on commit c8c1a5b

Please sign in to comment.