Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move CI to Github Actions, update Rubocop, fix Jruby tests #251

Merged
merged 5 commits into from May 14, 2024

Conversation

mrpasquini
Copy link
Contributor

@mrpasquini mrpasquini commented May 8, 2024

  • Move from Circle CI to Github Actions for rspec testing
  • Removed ReviewDog dependency for rubocop and updated to latest version.
  • Tests pass against Ruby 3, 3.1, 3.2, 3.3, jruby * Rails 6.1, 7.0, 7.1

 and Remove circle CI
@@ -8,6 +8,8 @@
module Apartment::PostgreSqlAdapterPatch
def default_sequence_name(table, _column)
res = super
res.delete!('"') # if rescued in super_method, trim leading and trailing quotes
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I dont love this as a fix for the failing jruby/postgres test.

The test was raising this error:

ActiveRecord::StatementInvalid: ActiveRecord::JDBCError: org.postgresql.util.PSQLException: ERROR: relation "db3.companies" does not exist
from arjdbc/jdbc/RubyJdbcConnection.java:1082:in `execute_query'

and being caught in the rescue block here:
https://github.com/jruby/activerecord-jdbc-adapter/blob/master/lib/arjdbc/postgresql/adapter.rb#L482-L484

If this is a data/setup issue for the jruby postgres tests, fixing the test setup would be more ideal. If this is a behavior issue with the jdbc driver, then this is more appropriate.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think the cleaner way would have been to:

From e76a571502caf6b06fc8ca6163d66013151455be Mon Sep 17 00:00:00 2001
From: Matt Pasquini <matt.pasquini@coupa.com>
Date: Tue, 14 May 2024 09:45:08 -0700
Subject: [PATCH] Move postgres jdbc fix to jdbc adapter

---
 lib/apartment/active_record/postgresql_adapter.rb | 1 -
 lib/apartment/adapters/jdbc_postgresql_adapter.rb | 4 ++++
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/lib/apartment/active_record/postgresql_adapter.rb b/lib/apartment/active_record/postgresql_adapter.rb
index 5426840..48526f1 100644
--- a/lib/apartment/active_record/postgresql_adapter.rb
+++ b/lib/apartment/active_record/postgresql_adapter.rb
@@ -8,7 +8,6 @@
 module Apartment::PostgreSqlAdapterPatch
   def default_sequence_name(table, _column)
     res = super
-    res.delete!('"') # if rescued in super_method, trim leading and trailing quotes
 
     schema_prefix = "#{Apartment::Tenant.current}."
     default_tenant_prefix = "#{Apartment::Tenant.default_tenant}."
diff --git a/lib/apartment/adapters/jdbc_postgresql_adapter.rb b/lib/apartment/adapters/jdbc_postgresql_adapter.rb
index 3e9494b..5fe245d 100644
--- a/lib/apartment/adapters/jdbc_postgresql_adapter.rb
+++ b/lib/apartment/adapters/jdbc_postgresql_adapter.rb
@@ -17,6 +17,10 @@ module Apartment
   module Adapters
     # Default adapter when not using Postgresql Schemas
     class JDBCPostgresqlAdapter < PostgresqlAdapter
+      def default_sequence_name
+        super.delete('"') # jdbc postgres adds quotes if rescued, trim leading and trailing quotes
+      end
+
       private
 
       def multi_tenantify_with_tenant_db_name(config, tenant)
-- 
2.37.3

Thought I dont think what is merged will cause any issue or regression.

Copy link
Collaborator

Choose a reason for hiding this comment

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

You can still add that. I do like it better

@mrpasquini mrpasquini changed the title Move CI to Github Actions and update Rubocop Move CI to Github Actions, update Rubocop, fix Jruby tests May 14, 2024
Silence jdbc mysql driver warning
strip leading and trailing quotes from default_sequence_name override for Postgre adapter.
@IanMcNelly IanMcNelly linked an issue May 14, 2024 that may be closed by this pull request
@IanMcNelly IanMcNelly merged commit 0f4c823 into rails-on-services:development May 14, 2024
15 checks passed
@mnovelo
Copy link
Collaborator

mnovelo commented May 14, 2024

thank you so much @IanMcNelly, @mrpasquini, @andyundso for working on this! I really appreciate your efforts

@mrpasquini mrpasquini deleted the github_actions branch May 15, 2024 18:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Release a new version that supports Rails 7.1
3 participants