Class: Raif::ApplicationRecord
- Inherits:
-
Object
- Object
- Raif::ApplicationRecord
- Includes:
- Concerns::BooleanTimestamp
- Defined in:
- app/models/raif/application_record.rb
Direct Known Subclasses
Agent, Conversation, ConversationEntry, ModelCompletion, ModelToolInvocation, Task, UserToolInvocation
Class Method Summary collapse
- .table_name_prefix ⇒ Object
-
.where_json_not_blank(column_name) ⇒ ActiveRecord::Relation
Returns a scope that checks if a JSON column is not blank (not null and not empty array).
Class Method Details
.table_name_prefix ⇒ Object
29 30 31 |
# File 'app/models/raif/application_record.rb', line 29 def self.table_name_prefix "raif_" end |
.where_json_not_blank(column_name) ⇒ ActiveRecord::Relation
Returns a scope that checks if a JSON column is not blank (not null and not empty array)
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'app/models/raif/application_record.rb', line 14 def self.where_json_not_blank(column_name) quoted_column = connection.quote_column_name(column_name.to_s) case connection.adapter_name.downcase when "postgresql" where.not(column_name => nil) .where("jsonb_array_length(#{quoted_column}) > 0") when "mysql2", "trilogy" where.not(column_name => nil) .where("JSON_LENGTH(#{quoted_column}) > 0") else raise "Unsupported database: #{connection.adapter_name}" end end |