Skip to content
Browse files

use primary_key method in OracleCompiler#select_sql

  • Loading branch information...
1 parent 20a10e5 commit 19c4de17ed40b323b5d771b81e28fe7b7490efc2 @rsim rsim committed Mar 1, 2010
Showing with 3 additions and 9 deletions.
  1. +3 −9 lib/arel/engines/sql/compilers/oracle_compiler.rb
View
12 lib/arel/engines/sql/compilers/oracle_compiler.rb
@@ -16,15 +16,9 @@ def select_sql
# when limit or offset subquery is used then cannot use FOR UPDATE directly
# and need to construct separate subquery for primary key
if use_subquery_for_lock = limit_or_offset && !locked.blank?
- primary_key = begin
- engine.quote_column_name(table.name.classify.constantize.primary_key)
- rescue NameError
- engine.quote_column_name("id")
- end
- select_attributes_string = primary_key
- else
- select_attributes_string = select_clauses.join(', ')
+ quoted_primary_key = engine.quote_column_name(primary_key)
end
+ select_attributes_string = use_subquery_for_lock ? quoted_primary_key : select_clauses.join(', ')
# OracleEnhanced adapter workaround when ORDER BY is used with columns not
# present in DISTINCT columns list
@@ -51,7 +45,7 @@ def select_sql
build_query \
"SELECT #{select_clauses.join(', ')}",
"FROM #{from_clauses}",
- "WHERE #{primary_key} IN (#{query})",
+ "WHERE #{quoted_primary_key} IN (#{query})",
"#{locked}"
elsif !locked.blank?
build_query query, "#{locked}"

0 comments on commit 19c4de1

Please sign in to comment.
Something went wrong with that request. Please try again.