Sha256: f59c7a496b75a43c22c672f57d36024fe42daf9e549576e1898432f4853386f8
Contents?: true
Size: 1.11 KB
Versions: 15
Compression:
Stored size: 1.11 KB
Contents
# frozen_string_literal: true 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
15 entries across 15 versions & 1 rubygems