diff --git a/lib/lotus/repository.rb b/lib/lotus/repository.rb index 507913b2..82bae064 100644 --- a/lib/lotus/repository.rb +++ b/lib/lotus/repository.rb @@ -551,6 +551,7 @@ def transaction(options = {}) end end + private # Executes the given raw statement on the adapter. # # Please note that it's only supported by some databases, @@ -595,7 +596,6 @@ def execute(raw) @adapter.execute(raw) end - private # Fabricates a query and yields the given block to access the low level # APIs exposed by the query itself. # diff --git a/test/fixtures.rb b/test/fixtures.rb index 7de3a1d4..eabe95dc 100644 --- a/test/fixtures.rb +++ b/test/fixtures.rb @@ -48,6 +48,10 @@ def self.not_by_user(user) def self.rank_by_user(user) rank.by_user(user) end + + def self.aggregate + execute("select * from articles") + end end DB = Sequel.connect(SQLITE_CONNECTION_STRING) diff --git a/test/repository_test.rb b/test/repository_test.rb index 0ed45e30..9f0134ac 100644 --- a/test/repository_test.rb +++ b/test/repository_test.rb @@ -453,9 +453,11 @@ def updated_at end describe '.execute' do + it 'is a private api' do + -> { ArticleRepository.execute("select * from users") }.must_raise NoMethodError + end it 'returns the ResultSet from the executes sql' do - sql = "select * from articles" - result = ArticleRepository.execute(sql) + result = ArticleRepository.aggregate result.class.name.must_equal "SQLite3::ResultSet" result.count.must_equal 1 end @@ -484,8 +486,11 @@ def updated_at end describe '.execute' do - it "an exception is raised because of memory adapter doesn't support execute" do - -> { ArticleRepository.execute("select * from users") }.must_raise NotImplementedError + it 'is a private api' do + -> { ArticleRepository.execute("select * from users") }.must_raise NoMethodError + end + it "raises an exception because memory adapter doesn't support execute" do + -> { ArticleRepository.aggregate }.must_raise NotImplementedError end end