Commits

Vladimir Mihailenco committed 6c25438

Fix mapping for sqlite; fix get() for manager; pass only protocol to SqlAlchemy

Comments (0)

Files changed (3)

djsqlalchemy/alchemy.py

     engine = SQLALCHEMY_ENGINES[engine]
     port = ':' + sett['PORT'] if sett['PORT'] else ''
 
-    str = '{engine}://{user}:{password}@{host}{port}/{name}'.format(
+    str = '{engine}://'.format(
         engine=engine, name=sett['NAME'], user=sett['USER'],
         password=sett['PASSWORD'], host=sett['HOST'], port=port)
 

djsqlalchemy/managers.py

 
     def get(self):
         if hasattr(self, 'result'):
-            return self.result.pop()
+            if not self.result:
+                raise self.model.DoesNotExist()
+            elif len(self.result) > 1:
+                raise self.model.MultipleObjectsReturned()
+            else:
+                return self.result.pop()
         else:
             return get_one(self.get_select(), self.model)
 

djsqlalchemy/mapper.py

 __all__ = ['fetchall', 'get_list', 'get_one']
 
 
-def map_related(obj, values, prefix='', counter=None):
+def map_related(obj, values, prefix=''):
     # special case for master obj
     local_prefix = prefix or (obj._meta.db_table + '_')
 
 
 def map_values(model, values):
     obj = model()
-    values = dict(values)
+
+    # TODO: replace with values = dict(values)
+    d = {}
+    for i, key in enumerate(values.keys()):
+        d[key] = values._row[i]
+    values = d
+
     map_related(obj, values)
 
     # set other values on master obj as is