Sha256: 324a0e90a60391c31ccbbb14a25059fda3b2c380816000ff9ef9f1710025d2a9
Contents?: true
Size: 1.08 KB
Versions: 1
Compression:
Stored size: 1.08 KB
Contents
module ROM module SQL module Plugin # Nullify relation by # # @api public module Nullify if defined? JRUBY_VERSION # Returns a relation that will never issue a query to the database. It # implements the null object pattern for relations. # Dataset#nullify doesn't work on JRuby, hence we fall back to SQL # # @api public def nullify where { `1 = 0` } end else # Returns a relation that will never issue a query to the database. It # implements the null object pattern for relations. # # @see http://sequel.jeremyevans.net/rdoc-plugins/files/lib/sequel/extensions/null_dataset_rb.html # @example result will always be empty, regardless if records exists # users.where(name: 'Alice').nullify # # @return [SQL::Relation] # # @api public def nullify new(dataset.where { `1 = 0` }.__send__(__method__)) end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rom-sql-3.1.0 | lib/rom/sql/plugin/nullify.rb |