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

Prepare Release 2.5.0 #44

Merged
merged 50 commits into from
May 5, 2020
Merged
Changes from 3 commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
841fbca
support rails 6.1, remove warnings
jean-francois-labbe Feb 13, 2020
54c9c72
fix rubocop
jean-francois-labbe Mar 23, 2020
504588e
Merge pull request #7 from jean-francois-labbe/fix-rails-6-1
rpbaltazar Apr 2, 2020
fa0f0f0
[#11] Remove old ruby and rails versions from the supported versions
rpbaltazar Mar 22, 2020
91b1d68
Fixing rubocop vesion and ignoring gemfiles
rpbaltazar Mar 22, 2020
ad32b08
[CI] removed unused exclusions
rpbaltazar Apr 2, 2020
d527441
[Chore] ran rubocop safe autocorrect
rpbaltazar Apr 2, 2020
b609d48
Remove test related files from gem
rpbaltazar Apr 2, 2020
23bcbbd
[Chore] fixed rubocop warning
rpbaltazar Apr 2, 2020
2e0256b
[Chore] refactored files to their names
rpbaltazar Apr 7, 2020
3213a4e
[Chore] removed commented block
rpbaltazar Apr 7, 2020
155f788
[i-27] Added tenant_connected_to to replace active record base connec…
rpbaltazar Apr 3, 2020
12cc206
[i-27] removed special method for switching tenant and adding alias f…
rpbaltazar Apr 3, 2020
2780a1e
[i-27] fix rubocop
rpbaltazar Apr 3, 2020
d145a51
[i-27] moving monkeypatches to their folders
rpbaltazar Apr 6, 2020
0595ff0
[i-27] Adding apartment model that resolves arel table based on apart…
rpbaltazar Apr 6, 2020
e50e324
[i-27] skiping table name modification if not using schemas
rpbaltazar Apr 7, 2020
b513bd8
[i-27] removed commented code
rpbaltazar Apr 7, 2020
72c0c32
[i-27] using config to enable schema prepend
rpbaltazar Apr 7, 2020
ed71488
[i-27] added prepend_tenant_name config to spec
rpbaltazar Apr 7, 2020
94de7f6
[i-27] renamed method
rpbaltazar Apr 7, 2020
2d1819d
[i-27] attempt to run tests with apartment model
rpbaltazar Apr 7, 2020
421d825
[i-27] updating test
rpbaltazar Apr 7, 2020
651288c
[i-27] creating schema
rpbaltazar Apr 7, 2020
be771ed
[i-27] fix test setup
rpbaltazar Apr 7, 2020
79e07f4
[i-27] fix failing test
rpbaltazar Apr 7, 2020
6e61591
[i-27] duplicate test coverage for jdbc postgresql adapter
rpbaltazar Apr 7, 2020
23e9e1e
[i-27] fix rubocop
rpbaltazar Apr 7, 2020
d3e695e
[i-27] updated readme
rpbaltazar Apr 7, 2020
27fc97a
[i-27] remove extra whitespaces
rpbaltazar Apr 7, 2020
29c7434
[i-27] for some reason there is an extra space in the output of to_sql
rpbaltazar Apr 7, 2020
f5b833f
using the other approach for updating the tenant based on the connect…
rpbaltazar Apr 8, 2020
55368fb
Fixed loading path
rpbaltazar Apr 8, 2020
c6eda8e
patch postgresql arel visit table to determine which schema to use
rpbaltazar Apr 8, 2020
f78afc9
cached find by statement to use tenant for cache key
rpbaltazar Apr 8, 2020
b0ad53c
Address rubocop errors
rpbaltazar Apr 8, 2020
b6bdcdf
Fixed failing specs
rpbaltazar Apr 8, 2020
d141639
Fixed cache key format. Added notes on cached find_by_statement
rpbaltazar Apr 9, 2020
ff12543
[Resolves #27] Some errors were being thrown due to caching issues
rpbaltazar Apr 9, 2020
5d76a8c
[#31] Updated travis ruby versions
rpbaltazar Apr 8, 2020
0ba04de
[#31] Added jruby head to test matrix
rpbaltazar Apr 8, 2020
6d754f5
[#31] Excluding 2.4.10 and rails 6 combination
rpbaltazar Apr 8, 2020
80bb3a4
[#31] Using bundler 2.x
rpbaltazar Apr 8, 2020
e260dfc
[#31] relaxed bundler development dependency
rpbaltazar Apr 9, 2020
8b32e93
[Resolves #31] Add latest ruby verisons to test matrix
rpbaltazar Apr 9, 2020
8b4723d
[#35] update cache key to use a string or an array depending on what …
rpbaltazar Apr 9, 2020
8439fc4
[Resolves #35] update cache key to use a string or an array
rpbaltazar Apr 9, 2020
b27311d
Added before hook to connected to to try to set the tenant
rpbaltazar Apr 14, 2020
3fa374a
[Chore] Removed references to allow prepend tenant name
rpbaltazar Apr 15, 2020
b19ba24
[Resolves #27] Added before hook to connected to to try to set the te…
rpbaltazar Apr 15, 2020
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
32 changes: 30 additions & 2 deletions lib/apartment.rb
Original file line number Diff line number Diff line change
@@ -6,6 +6,26 @@
require 'active_record'
require 'apartment/tenant'

if ActiveRecord.version.release >= Gem::Version.new('6.1')
module ActiveRecord
class SchemaMigration < ActiveRecord::Base # :nodoc: # rubocop:disable Rails/ApplicationRecord
class << self
def table_exists?
connection.table_exists?(table_name)
end
end
end

class InternalMetadata < ActiveRecord::Base # :nodoc: # rubocop:disable Rails/ApplicationRecord
class << self
def table_exists?
connection.table_exists?(table_name)
end
end
end
end
end

module Apartment
class << self
extend Forwardable
@@ -21,7 +41,15 @@ class << self
attr_accessor(*ACCESSOR_METHODS)
attr_writer(*WRITER_METHODS)

def_delegators :connection_class, :connection, :connection_config, :establish_connection
if ActiveRecord.version.release >= Gem::Version.new('6.1')
def_delegators :connection_class, :connection, :connection_db_config, :establish_connection

def connection_config
connection_db_config.configuration_hash
end
else
def_delegators :connection_class, :connection, :connection_config, :establish_connection
end

# configure apartment with available options
def configure
@@ -37,7 +65,7 @@ def tenants_with_config
end

def db_config_for(tenant)
(tenants_with_config[tenant] || connection_config).with_indifferent_access
(tenants_with_config[tenant] || connection_config)
end

# Whether or not db:migrate should also migrate tenants
2 changes: 1 addition & 1 deletion lib/apartment/adapters/abstract_adapter.rb
Original file line number Diff line number Diff line change
@@ -230,7 +230,7 @@ def rescue_from
end

def db_connection_config(tenant)
Apartment.db_config_for(tenant).clone
Apartment.db_config_for(tenant).dup
end

def with_neutral_connection(tenant, &_block)