Sha256: d0dfdbfd213c388fa60ee7a46d71cc619c9dc29f8405505d0fde60a39a262aec
Contents?: true
Size: 916 Bytes
Versions: 3
Compression:
Stored size: 916 Bytes
Contents
# frozen_string_literal: true module CanCan module ModelAdapters class Strategies class JoinedAliasExistsSubquery < Base def execute! model_class .joins( "JOIN #{quoted_table_name} AS #{quoted_aliased_table_name} ON " \ "#{quoted_aliased_table_name}.#{quoted_primary_key} = #{quoted_table_name}.#{quoted_primary_key}" ) .where("EXISTS (#{joined_alias_exists_subquery_inner_query.to_sql})") end def joined_alias_exists_subquery_inner_query model_class .unscoped .select('1') .left_joins(joins) .where(*where_conditions) .where( "#{quoted_table_name}.#{quoted_primary_key} = " \ "#{quoted_aliased_table_name}.#{quoted_primary_key}" ) .limit(1) end end end end end
Version data entries
3 entries across 3 versions & 2 rubygems