Class: ActiveRecord::Base

Inherits:
Object show all
Defined in:
lib/dolzenko/django_f_object.rb,
lib/dolzenko/django_f_object.rb,
lib/dolzenko/django_q_object.rb

Direct Known Subclasses

User

Class Method Summary collapse

Class Method Details

.my_quote_columns(*column_names) ⇒ Object



79
80
81
82
# File 'lib/dolzenko/django_f_object.rb', line 79

def self.my_quote_columns(*column_names)
  quoted_table_name = connection.quote_table_name(table_name)
  column_names.map { |column_name| "#{ quoted_table_name }.#{ connection.quote_column_name(column_name) }" }.join(", ")
end

.Q(*args) ⇒ Object



133
134
135
# File 'lib/dolzenko/django_q_object.rb', line 133

def self.Q(*args)
  UnaryQ.new(*args).to_q_sql(self)
end

.sanitize_sql_hash_for_assignment_with_f_object(assignments) ⇒ Object



114
115
116
117
118
119
120
121
122
123
124
# File 'lib/dolzenko/django_f_object.rb', line 114

def sanitize_sql_hash_for_assignment_with_f_object(assignments)
  f_assignments, normal_assignments = assignments.partition { |_, v| v.is_a?(F) }
  
  f_sql = f_assignments.map do |attr, f_obj|
    "#{connection.quote_column_name(attr)} = #{connection.quote_column_name(f_obj.attr_name)}"
  end.join(", ")

  normal_sql = sanitize_sql_hash_for_assignment_without_f_object(normal_assignments)
  
  [(f_sql if f_sql.present?), (normal_sql if normal_sql.present?)].compact.join(", ")
end