Skip to content

Commit

Permalink
Remove every new line when generating queries, this may build invalid…
Browse files Browse the repository at this point in the history
… queries on SQLite.
  • Loading branch information
miloops committed Dec 31, 2009
1 parent 818f019 commit 5f23dad
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions lib/arel/engines/sql/relations/relation.rb
Expand Up @@ -15,7 +15,7 @@ def select_sql
"SELECT #{select_clauses.kind_of?(::Array) ? select_clauses.join("") : select_clauses.to_s}",
"FROM #{from_clauses}",
(joins(self) unless joins(self).blank? ),
("WHERE #{where_clauses.join("\n\tAND ")}" unless wheres.blank? ),
("WHERE #{where_clauses.join(" AND ")}" unless wheres.blank? ),
("GROUP BY #{group_clauses.join(', ')}" unless groupings.blank? ),
("HAVING #{having_clauses.join(', ')}" unless havings.blank? ),
("#{locked}" unless locked.blank? )
Expand All @@ -31,7 +31,7 @@ def select_sql
"SELECT #{select_clauses.join(', ')}",
"FROM #{from_clauses}",
(joins(self) unless joins(self).blank? ),
("WHERE #{where_clauses.join("\n\tAND ")}" unless wheres.blank? ),
("WHERE #{where_clauses.join(" AND ")}" unless wheres.blank? ),
("GROUP BY #{group_clauses.join(', ')}" unless groupings.blank? ),
("HAVING #{having_clauses.join(', ')}" unless havings.blank? ),
("ORDER BY #{order_clauses.join(', ')}" unless orders.blank? ),
Expand Down
6 changes: 3 additions & 3 deletions lib/arel/engines/sql/relations/writes.rb
Expand Up @@ -4,7 +4,7 @@ def to_sql
build_query \
"DELETE",
"FROM #{table_sql}",
("WHERE #{wheres.collect(&:to_sql).join('\n\tAND ')}" unless wheres.blank? ),
("WHERE #{wheres.collect(&:to_sql).join(' AND ')}" unless wheres.blank? ),
("LIMIT #{taken}" unless taken.blank? )
end
end
Expand Down Expand Up @@ -55,15 +55,15 @@ def assignment_sql
attributes.map do |attribute|
value = assignments[attribute]
"#{engine.quote_column_name(attribute.name)} = #{attribute.format(value)}"
end.join(",\n")
end.join(", ")
else
assignments.value
end
end

def build_update_conditions_sql
conditions = ""
conditions << " WHERE #{wheres.collect(&:to_sql).join('\n\tAND ')}" unless wheres.blank?
conditions << " WHERE #{wheres.collect(&:to_sql).join(' AND ')}" unless wheres.blank?
conditions << " ORDER BY #{order_clauses.join(', ')}" unless orders.blank?

unless taken.blank?
Expand Down

0 comments on commit 5f23dad

Please sign in to comment.