Untitled diff

Created Diff never expires
4 削除
合計
削除
単語
合計
削除
この機能を引き続き使用するには、アップグレードしてください
Diffchecker logo
Diffchecker Pro
6
10 追加
合計
追加
単語
合計
追加
この機能を引き続き使用するには、アップグレードしてください
Diffchecker logo
Diffchecker Pro
12
def new_search_condition(column, value)
def new_search_condition(column, value)
model, column = column.split('.')
model, column, attribute = column.split('.')
model = model.constantize
model = model.constantize
casted_column = ::Arel::Nodes::NamedFunction.new('CAST', [model.arel_table[column.to_sym].as(typecast)])
if model.columns_hash[column].sql_type == 'json'
casted_column.matches("%#{sanitize_sql_like(value)}%")
Arel.sql("JSON_EXTRACT(#{column}, '$.#{attribute}')")
end
else
::Arel::Nodes::NamedFunction.new(
'CAST', [model.arel_table[column.to_sym].as(typecast)]
)
end.matches("%#{value}%")
end