README.md in sequel-rails-1.1.1 vs README.md in sequel-rails-1.2.0
- old
+ new
@@ -1,18 +1,17 @@
# sequel-rails
[][gem]
-[][travis]
+
[][codeclimate]
[gem]: https://rubygems.org/gems/sequel-rails
-[travis]: http://travis-ci.org/TalentBox/sequel-rails
[codeclimate]: https://codeclimate.com/github/TalentBox/sequel-rails
This gem provides the railtie that allows
[sequel](http://github.com/jeremyevans/sequel) to hook into
-[Rails (4.x and 5.x)](http://github.com/rails/rails) and thus behave like a
+[Rails (5.2.x, 6.x, 7.x)](http://github.com/rails/rails) and thus behave like a
rails framework component. Just like activerecord does in rails,
[sequel-rails](http://github.com/talentbox/sequel-rails) uses the railtie API to
hook into rails. The two are actually hooked into rails almost identically.
The code for this gem was initially taken from the excellent
@@ -26,11 +25,11 @@
[brasten](https://github.com/brasten) proposed us.
Using sequel-rails
==================
-Using sequel with Rails (4.x or 5.x) requires a couple minor changes.
+Using sequel with Rails (5.2.x, 6.x, 7.x) requires a couple minor changes.
First, add the following to your Gemfile (after the `Rails` lines):
```ruby
# depending on you database
@@ -193,10 +192,21 @@
# Configure if Sequel should try to 'test' the database connection in order
# to fail early
config.sequel.test_connect = true
+ # Configure what should happend after SequelRails will create new connection with Sequel (applicable only for the first new connection)
+ # config.sequel.after_connect = proc do
+ # Sequel::Model.plugin :timestamps, update_on_create: true
+ # end
+
+ # Configure what should happend after new connection in connection pool is created (applicable only for all connections)
+ # to fail early
+ # config.sequel.after_new_connection = proc do |db|
+ # db.execute('SET statement_timeout = 30000;')
+ # end
+
# If you want to use a specific logger
config.sequel.logger = MyLogger.new($stdout)
```
The connection settings are read from the file `config/database.yml` and is
@@ -257,10 +267,29 @@
development:
adapter: sqlite # Also accept sqlite3
database: ":memory:"
```
+after_connect hooks
+================
+
+There are 2 options how to set after_connect hooks in `config/application.rb`
+
+ 1. `config.sequel.after_connect` will be called only on the first new connection. It can be used for enabling plugins or to set some global sequel settings.
+ ```ruby
+ config.sequel.after_connect = proc do
+ Sequel::Model.plugin :timestamps, update_on_create: true
+ end
+ ```
+
+ 2. `config.sequel.after_new_connection` will be called after every new connection in connection pool is created. It can be used to run some specific `SET` commands on every new connection. It's using default `after_connect` hook in sequel. https://sequel.jeremyevans.net/rdoc/classes/Sequel/ConnectionPool.html#attribute-i-after_connect
+ ```ruby
+ config.sequel.after_new_connection = proc do |db|
+ db.execute('SET statement_timeout = 30000;')
+ end
+ ```
+
Enabling plugins
================
If you want to enable plugins for all your models, you should use the
after_connect configuration option in `config/application.rb` (0.6.2+):
@@ -356,19 +385,19 @@
* Send me a pull request. Bonus points for topic branches.
The sequel-rails team
=====================
-* Jonathan Tron (JonathanTron) - Current maintainer
-* Joseph Halter (JosephHalter) - Current maintainer
+* Jonathan Tron (@JonathanTron) - Current maintainer
+* Joseph Halter (@JosephHalter) - Current maintainer
Previous maintainer
===================
[Original project](https://github.com/brasten/sequel-rails):
-* Brasten Sager (brasten) - Project creator
+* Brasten Sager (@brasten) - Project creator
Contributors
============
Improvements have been made by those awesome contributors:
@@ -415,15 +444,19 @@
* Dustin Byrne (@dsbyrne)
* Michael Coyne (@mjc-gh)
* p-leger (@p-leger)
* Semyon Pupkov (@artofhuman)
* Ben Koshy (@BKSpurgeon)
+* Janko Marohnić (@janko)
+* Adrián Mugnolo (@xymbol)
+* Ivan (@AnotherRegularDude)
+* kamilpavlicko (@kamilpavlicko)
Credits
=======
The [dm-rails](http://github.com/datamapper/dm-rails) team wrote most of the original code, I just sequel-ized it, but since then most of it has been either adapted or rewritten.
Copyright
=========
-Copyright (c) 2010-2013 The sequel-rails team. See [LICENSE](http://github.com/brasten/sequel-rails/blob/master/LICENSE) for details.
+Copyright (c) 2010-2022 The sequel-rails team. See [LICENSE](http://github.com/brasten/sequel-rails/blob/master/LICENSE) for details.