No commit activity in last 3 years
No release in over 3 years
This extension hooks into `Sequel::Dataset#all` method, doing some predefined action when an `SELECT *` statement is found.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

~> 0.63.0
~> 5.10
 Project Readme

SequelAsteriskHunter

Maintainability

This extension hooks into Sequel::Dataset#fetch_rows method, doing some predefined action when an SELECT * statement is found.

Installation

Add this line to your application's Gemfile:

gem 'sequel-asterisk-hunter'

And then execute:

$ bundle

Or install it yourself as:

$ gem install sequel-asterisk-hunter

Usage

The extension needs to be initialized by the Sequel extension interface. The simplest way to configure it globally is by adding this line to the initializer:

Sequel.extension :asterisk_hunter

or

Sequel::Database.extension :asterisk_hunter

However, if you are using any framework (like Rails) where your Sequel::Database instance already exists, you should use DB.extension :asterisk_hunter, where DB is a reference to your Sequel::Database, like this:

Sequel::Model.db.extension :asterisk_hunter

You could define an action to be executed when any SELECT * statement is found. It must be any callable object.

Examples

With the default action:

DB[:my_table].all
  #=> "Find 'SELECT *' in query!"
  #=> [<All your objects and its attributes/columns>]

With some custom actions defined:

  • Raising an error:
action = -> { raise StandardError, "Find 'SELECT *' in query!" }
Sequel::Extensions::AsteriskHunter.define_action(action)

DB[:my_table].all
  #=> StandardError("Find 'SELECT *' in query!")
  # (Your query is not executed...)
  • Logging:
action = -> { Rails.logger.warn("Find 'SELECT *' in query!") }
Sequel::Extensions::AsteriskHunter.define_action(action)

DB[:my_table].all
  #=> "Find 'SELECT *' in query!"
  #=> [<All your objects and its attributes/columns>]

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request