summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/mapping
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2006-02-25 07:12:50 +0000
committerMike Bayer <mike_mp@zzzcomputing.com>2006-02-25 07:12:50 +0000
commit72dd2b08beb9803269983aa220e75b44007e5158 (patch)
tree16f80b5f869ba68ae17e2fcbe9b18f1542b22e84 /lib/sqlalchemy/mapping
parent5b81c1a2d0915d95d9928ffaaf81af814cf4ec3e (diff)
downloadsqlalchemy-72dd2b08beb9803269983aa220e75b44007e5158.tar.gz
merged sql_rearrangement branch , refactors sql package to work standalone with
clause elements including tables and columns, schema package deals with "physical" representations
Diffstat (limited to 'lib/sqlalchemy/mapping')
-rw-r--r--lib/sqlalchemy/mapping/mapper.py6
-rw-r--r--lib/sqlalchemy/mapping/objectstore.py17
2 files changed, 11 insertions, 12 deletions
diff --git a/lib/sqlalchemy/mapping/mapper.py b/lib/sqlalchemy/mapping/mapper.py
index 61d9a3c2e..33bec863e 100644
--- a/lib/sqlalchemy/mapping/mapper.py
+++ b/lib/sqlalchemy/mapping/mapper.py
@@ -262,7 +262,7 @@ class Mapper(object):
"""returns an instance of the object based on the given identifier, or None
if not found. The *ident argument is a
list of primary key columns in the order of the table def's primary key columns."""
- key = objectstore.get_id_key(ident, self.class_, self.primarytable)
+ key = objectstore.get_id_key(ident, self.class_)
#print "key: " + repr(key) + " ident: " + repr(ident)
return self._get(key, ident)
@@ -284,7 +284,7 @@ class Mapper(object):
def identity_key(self, *primary_key):
- return objectstore.get_id_key(tuple(primary_key), self.class_, self.primarytable)
+ return objectstore.get_id_key(tuple(primary_key), self.class_)
def instance_key(self, instance):
return self.identity_key(*[self._getattrbycolumn(instance, column) for column in self.pks_by_table[self.table]])
@@ -683,7 +683,7 @@ class Mapper(object):
return statement
def _identity_key(self, row):
- return objectstore.get_row_key(row, self.class_, self.identitytable, self.pks_by_table[self.table])
+ return objectstore.get_row_key(row, self.class_, self.pks_by_table[self.table])
def _instance(self, row, imap, result = None, populate_existing = False):
"""pulls an object instance from the given row and appends it to the given result
diff --git a/lib/sqlalchemy/mapping/objectstore.py b/lib/sqlalchemy/mapping/objectstore.py
index 311a6c542..4f0dc4daf 100644
--- a/lib/sqlalchemy/mapping/objectstore.py
+++ b/lib/sqlalchemy/mapping/objectstore.py
@@ -48,7 +48,7 @@ class Session(object):
self.hash_key = hash_key
_sessions[self.hash_key] = self
- def get_id_key(ident, class_, table):
+ def get_id_key(ident, class_):
"""returns an identity-map key for use in storing/retrieving an item from the identity
map, given a tuple of the object's primary key values.
@@ -62,10 +62,10 @@ class Session(object):
selectable - a Selectable object which represents all the object's column-based fields.
this Selectable may be synonymous with the table argument or can be a larger construct
containing that table. return value: a tuple object which is used as an identity key. """
- return (class_, table.hash_key(), tuple(ident))
+ return (class_, tuple(ident))
get_id_key = staticmethod(get_id_key)
- def get_row_key(row, class_, table, primary_key):
+ def get_row_key(row, class_, primary_key):
"""returns an identity-map key for use in storing/retrieving an item from the identity
map, given a result set row.
@@ -80,7 +80,7 @@ class Session(object):
this Selectable may be synonymous with the table argument or can be a larger construct
containing that table. return value: a tuple object which is used as an identity key.
"""
- return (class_, table.hash_key(), tuple([row[column] for column in primary_key]))
+ return (class_, tuple([row[column] for column in primary_key]))
get_row_key = staticmethod(get_row_key)
class SessionTrans(object):
@@ -181,7 +181,6 @@ class Session(object):
return None
key = getattr(instance, '_instance_key', None)
mapper = object_mapper(instance)
- key = (key[0], mapper.table.hash_key(), key[2])
u = self.uow
if key is not None:
if u.identity_map.has_key(key):
@@ -194,11 +193,11 @@ class Session(object):
u.register_new(instance)
return instance
-def get_id_key(ident, class_, table):
- return Session.get_id_key(ident, class_, table)
+def get_id_key(ident, class_):
+ return Session.get_id_key(ident, class_)
-def get_row_key(row, class_, table, primary_key):
- return Session.get_row_key(row, class_, table, primary_key)
+def get_row_key(row, class_, primary_key):
+ return Session.get_row_key(row, class_, primary_key)
def begin():
"""begins a new UnitOfWork transaction. the next commit will affect only