Skip to content

Commit

Permalink
Set convert_id_token_to_integer? to avoid DB queries on boot
Browse files Browse the repository at this point in the history
Closes #244
  • Loading branch information
janko committed Nov 19, 2023
1 parent 4881455 commit d8b3f43
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## HEAD

* Set `convert_token_id_to_integer?` in default configuration to avoid DB queries on boot (@janko)

## 1.12.0 (2023-10-20)

* Allow generating view template for `confirm_password` feature (igor-alexandrov)
Expand Down
4 changes: 4 additions & 0 deletions lib/generators/rodauth/install_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ def argon2?
options[:argon2]
end

def primary_key_integer?
!::Rails.configuration.generators.options[:active_record][:primary_key_type]
end

def sequel_activerecord_integration?
defined?(ActiveRecord::Railtie) &&
(!defined?(Sequel) || Sequel::DATABASES.empty?)
Expand Down
2 changes: 2 additions & 0 deletions lib/generators/rodauth/templates/app/misc/rodauth_main.rb.tt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ class RodauthMain < Rodauth::Rails::Auth
db Sequel.<%= sequel_adapter %>(extensions: :activerecord_connection, keep_reference: false)
<% end -%>

convert_token_id_to_integer? <%= primary_key_integer? %>

<% end -%>
# Change prefix of table and foreign key column names from default "account"
<% if table -%>
Expand Down
1 change: 1 addition & 0 deletions test/generators/install_generator_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class InstallGeneratorTest < Rails::Generators::TestCase
else
assert_file "app/misc/rodauth_main.rb", %r{Sequel\.sqlite\(extensions: :activerecord_connection.*\)}
end
assert_file "app/misc/rodauth_main.rb", /convert_token_id_to_integer\? true/
end

test "app" do
Expand Down

0 comments on commit d8b3f43

Please sign in to comment.