Skip to content

Commit

Permalink
Fix Database::Sequel served relation + more friendly require
Browse files Browse the repository at this point in the history
  • Loading branch information
blambeau committed Jun 27, 2024
1 parent 17d59ec commit 6cc2abe
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
* Add `Summarizer.bucketize` to distribute attribute values in a number of
buckets. We support :boundaries, :value_length and :distinct options.

* `require 'bmg/sequel` automatically requires `bmg` itself.

## 0.22.0 - 2024-05-17

* Add the `minus` operation (also known as set difference, or EXCEPT in SQL).
Expand Down
4 changes: 2 additions & 2 deletions lib/bmg/database/sequel.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ class Sequel < Database

def initialize(sequel_db, options = {})
@sequel_db = sequel_db
@sequel_db = ::Sequel.connect(@sequel_db) unless @sequel_db.is_a?(::Sequel::Database)
end

def method_missing(name, *args, &bl)
return super(name, *args, &bl) unless args.empty? && bl.nil?
raise NotSuchRelationError(name.to_s) unless @sequel_db.table_exists?(name)
table = @sequel_db[name]
rel_for(table)
rel_for(name)
end

def each_relation_pair
Expand Down
1 change: 1 addition & 0 deletions lib/bmg/sequel.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
require 'bmg'
require 'bmg/sql'
require 'sequel'
require 'predicate/sequel'
Expand Down

0 comments on commit 6cc2abe

Please sign in to comment.