lib/unread/reader_scopes.rb in unread-0.13.1 vs lib/unread/reader_scopes.rb in unread-0.14.0

- old
+ new

@@ -10,11 +10,11 @@ def join_read_marks(readable) assert_readable(readable) joins "LEFT JOIN #{ReadMark.quoted_table_name} ON #{ReadMark.quoted_table_name}.readable_type = '#{readable.class.readable_parent.name}' - AND (#{ReadMark.quoted_table_name}.readable_id = #{quote_bound_value(readable.id)} OR #{ReadMark.quoted_table_name}.readable_id IS NULL) + AND (#{ReadMark.quoted_table_name}.readable_id = #{quoted(readable.id)} OR #{ReadMark.quoted_table_name}.readable_id IS NULL) AND #{ReadMark.quoted_table_name}.reader_id = #{quoted_table_name}.#{quoted_primary_key} AND #{ReadMark.quoted_table_name}.reader_type = '#{connection.quote_string base_class.name}' AND #{ReadMark.quoted_table_name}.timestamp >= '#{connection.quoted_date readable.send(readable.class.readable_options[:on])}'" end @@ -29,11 +29,19 @@ def with_read_marks_for(readable) postgresql_string_cast = using_postgresql? ? '::varchar' : '' join_read_marks(readable).select("#{quoted_table_name}.*, #{ReadMark.quoted_table_name}.id AS read_mark_id, - #{quote_bound_value(readable.class.name)}#{postgresql_string_cast} AS read_mark_readable_type, - #{quote_bound_value(readable.id)} AS read_mark_readable_id") + #{quoted(readable.class.name)}#{postgresql_string_cast} AS read_mark_readable_type, + #{quoted(readable.id)} AS read_mark_readable_id") + end + + def quoted(value) + if Gem::Version.new(ActiveRecord::VERSION::STRING) >= Gem::Version.new('7.2') + quote_bound_value(connection, value) + else + quote_bound_value(value) + end end end end end