Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

cache primary key per engine connection, updated gemspec file

  • Loading branch information...
commit 07dcfd4ea7c052063e912ab479f64da78848a66e 1 parent 19c4de1
@rsim rsim authored
Showing with 13 additions and 5 deletions.
  1. +7 −1 arel.gemspec
  2. +6 −4 lib/arel/engines/sql/relations/relation.rb
View
8 arel.gemspec
@@ -6,7 +6,7 @@ Gem::Specification.new do |s|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Bryan Helmkamp", "Nick Kallen", "Emilio Tagua"]
- s.date = %q{2010-02-13}
+ s.date = %q{2010-03-01}
s.description = %q{Arel is a Relational Algebra for Ruby. It 1) simplifies the generation complex
of SQL queries and it 2) adapts to various RDBMS systems. It is intended to be
a framework framework; that is, you can build your own ORM with it, focusing on
@@ -69,6 +69,11 @@ and query generation.}
"lib/arel/engines/memory/relations/writes.rb",
"lib/arel/engines/sql.rb",
"lib/arel/engines/sql/christener.rb",
+ "lib/arel/engines/sql/compilers/ibm_db_compiler.rb",
+ "lib/arel/engines/sql/compilers/mysql_compiler.rb",
+ "lib/arel/engines/sql/compilers/oracle_compiler.rb",
+ "lib/arel/engines/sql/compilers/postgresql_compiler.rb",
+ "lib/arel/engines/sql/compilers/sqlite_compiler.rb",
"lib/arel/engines/sql/core_extensions.rb",
"lib/arel/engines/sql/core_extensions/array.rb",
"lib/arel/engines/sql/core_extensions/nil_class.rb",
@@ -79,6 +84,7 @@ and query generation.}
"lib/arel/engines/sql/predicates.rb",
"lib/arel/engines/sql/primitives.rb",
"lib/arel/engines/sql/relations.rb",
+ "lib/arel/engines/sql/relations/compiler.rb",
"lib/arel/engines/sql/relations/operations/alias.rb",
"lib/arel/engines/sql/relations/operations/join.rb",
"lib/arel/engines/sql/relations/relation.rb",
View
10 lib/arel/engines/sql/relations/relation.rb
@@ -1,6 +1,6 @@
module Arel
class Relation
- @@tables_primary_keys = {}
+ @@connection_tables_primary_keys = {}
def compiler
@compiler ||= begin
@@ -23,10 +23,12 @@ def inclusion_predicate_sql
end
def primary_key
- if @@tables_primary_keys.has_key?(table.name)
- @@tables_primary_keys[table.name]
+ connection_id = engine.connection.object_id
+ if @@connection_tables_primary_keys[connection_id] && @@connection_tables_primary_keys[connection_id].has_key?(table.name)
+ @@connection_tables_primary_keys[connection_id][table.name]
else
- @@tables_primary_keys[table.name] = engine.primary_key(table.name)
+ @@connection_tables_primary_keys[connection_id] ||= {}
+ @@connection_tables_primary_keys[connection_id][table.name] = engine.connection.primary_key(table.name)
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.