Skip to content

Commit

Permalink
Merge pull request #3298 from manyfold3d/fix-postgres-detection
Browse files Browse the repository at this point in the history
Check database adapter name rather than class in regex checks
  • Loading branch information
Floppy authored Dec 10, 2024
2 parents 89dbab3 + 013e5bd commit 9e294b6
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/controllers/concerns/filterable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def filter_by_missing_tag(models, missingtag, library)
tag_regex_build = []
regexes = ((missingtag != "") ? [missingtag] : Library.find_param(library).tag_regex)
# Regexp match syntax - postgres is different from MySQL and SQLite
regact = ApplicationRecord.connection.is_a?(ActiveRecord::ConnectionAdapters::PostgreSQLAdapter) ? "~" : "REGEXP"
regact = (ApplicationRecord.connection.adapter_name == "PostgreSQL") ? "~" : "REGEXP"
regexes.each do |reg|
qreg = ActiveRecord::Base.connection.quote(reg)
tag_regex_build.push "(select count(*) from tags join taggings on tags.id=taggings.tag_id where tags.name #{regact} #{qreg} and taggings.taggable_id=models.id and taggings.taggable_type='Model')<1"
Expand Down
2 changes: 1 addition & 1 deletion app/views/application/_tag_list.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<% if @models
tierunset = tiers.map { |tier|
reg = ActiveRecord::Base.connection.quote("^" + tier + ":")
regact = ApplicationRecord.connection.is_a?(ActiveRecord::ConnectionAdapters::PostgreSQLAdapter) ? "~" : "REGEXP"
regact = (ApplicationRecord.connection.adapter_name == "PostgreSQL") ? "~" : "REGEXP"
[tier, @models.where("(select count(*) from tags join taggings on tags.id=taggings.tag_id where tags.name #{regact} #{reg} and taggings.taggable_id=models.id and taggings.taggable_type='Model')<1").count]
}.to_h
end %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/layouts/settings.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
<li class="nav-item">
<%= link_to t(".sidekiq"), sidekiq_web_path, class: "nav-link" %>
</li>
<% if defined?(ActiveRecord::ConnectionAdapters::PostgreSQLAdapter) && ApplicationRecord.connection.is_a?(ActiveRecord::ConnectionAdapters::PostgreSQLAdapter) %>
<% if ApplicationRecord.connection.adapter_name == "PostgreSQL" %>
<li class="nav-item">
<%= link_to t(".pghero"), pg_hero_path, class: "nav-link" %>
</li>
Expand Down

0 comments on commit 9e294b6

Please sign in to comment.