Skip to content

Commit c8c1a5b

Browse files
authored
Merge pull request #1164 from JesseChavez/more_rails_71_fixes
jdbc-mysql gem fix and some AR postgres fixes
2 parents 0a959b8 + 28f4b0c commit c8c1a5b

File tree

4 files changed

+23
-17
lines changed

4 files changed

+23
-17
lines changed

jdbc-mysql/lib/jdbc/mysql.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ module Jdbc
55
module MySQL
66

77
def self.driver_jar
8-
"mysql-connector-java-#{DRIVER_VERSION}.jar"
8+
"mysql-connector-j-#{DRIVER_VERSION}.jar"
99
end
1010

1111
def self.load_driver(method = :load)

lib/arjdbc/abstract/database_statements.rb

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -78,18 +78,6 @@ def exec_update(sql, name = 'SQL', binds = NO_BINDS)
7878
end
7979
alias :exec_delete :exec_update
8080

81-
def execute(sql, name = nil, async: false, allow_retry: false, materialize_transactions: true)
82-
sql = transform_query(sql)
83-
84-
if preventing_writes? && write_query?(sql)
85-
raise ActiveRecord::ReadOnlyError, "Write query attempted while in readonly mode: #{sql}"
86-
end
87-
88-
mark_transaction_written_if_write(sql)
89-
90-
raw_execute(sql, name, async: async, allow_retry: allow_retry, materialize_transactions: materialize_transactions)
91-
end
92-
9381
# overridden to support legacy binds
9482
def select_all(arel, name = nil, binds = NO_BINDS, preparable: nil, async: false)
9583
binds = convert_legacy_binds_to_attributes(binds) if binds.first.is_a?(Array)
@@ -107,7 +95,9 @@ def convert_legacy_binds_to_attributes(binds)
10795
def raw_execute(sql, name, async: false, allow_retry: false, materialize_transactions: true)
10896
log(sql, name, async: async) do
10997
with_raw_connection(allow_retry: allow_retry, materialize_transactions: materialize_transactions) do |conn|
110-
conn.execute(sql)
98+
result = conn.execute(sql)
99+
verified!
100+
result
111101
end
112102
end
113103
end

lib/arjdbc/postgresql/adapter.rb

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -787,6 +787,25 @@ def jdbc_connection_class
787787
def new_client(conn_params, adapter_instance)
788788
jdbc_connection_class.new(conn_params, adapter_instance)
789789
end
790+
791+
def dbconsole(config, options = {})
792+
pg_config = config.configuration_hash
793+
794+
ENV["PGUSER"] = pg_config[:username] if pg_config[:username]
795+
ENV["PGHOST"] = pg_config[:host] if pg_config[:host]
796+
ENV["PGPORT"] = pg_config[:port].to_s if pg_config[:port]
797+
ENV["PGPASSWORD"] = pg_config[:password].to_s if pg_config[:password] && options[:include_password]
798+
ENV["PGSSLMODE"] = pg_config[:sslmode].to_s if pg_config[:sslmode]
799+
ENV["PGSSLCERT"] = pg_config[:sslcert].to_s if pg_config[:sslcert]
800+
ENV["PGSSLKEY"] = pg_config[:sslkey].to_s if pg_config[:sslkey]
801+
ENV["PGSSLROOTCERT"] = pg_config[:sslrootcert].to_s if pg_config[:sslrootcert]
802+
if pg_config[:variables]
803+
ENV["PGOPTIONS"] = pg_config[:variables].filter_map do |name, value|
804+
"-c #{name}=#{value.to_s.gsub(/[ \\]/, '\\\\\0')}" unless value == ":default" || value == :default
805+
end.join(" ")
806+
end
807+
find_cmd_and_exec("psql", config.database)
808+
end
790809
end
791810

792811
def initialize(...)

test/db/postgresql/table_name_test.rb

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,6 @@ class SerialWithTrigger < ActiveRecord::Base
8787
end
8888

8989
def test_serial_with_trigger
90-
pend "Issue happens in active record 7.1 internals, issue wass logged in rails repo"
91-
# issue link: https://github.com/rails/rails/issues/52485
92-
9390
sn = SerialWithTrigger.create!(value: 1_234_567_890.to_s)
9491

9592
assert sn.reload

0 commit comments

Comments
 (0)