summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/processors.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sqlalchemy/processors.py')
-rw-r--r--lib/sqlalchemy/processors.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/sqlalchemy/processors.py b/lib/sqlalchemy/processors.py
index c4bac2834..a3adbe293 100644
--- a/lib/sqlalchemy/processors.py
+++ b/lib/sqlalchemy/processors.py
@@ -20,6 +20,7 @@ def str_to_datetime_processor_factory(regexp, type_):
rmatch = regexp.match
# Even on python2.6 datetime.strptime is both slower than this code
# and it does not support microseconds.
+ has_named_groups = bool(regexp.groupindex)
def process(value):
if value is None:
return None
@@ -32,7 +33,12 @@ def str_to_datetime_processor_factory(regexp, type_):
if m is None:
raise ValueError("Couldn't parse %s string: "
"'%s'" % (type_.__name__ , value))
- return type_(*map(int, m.groups(0)))
+ if has_named_groups:
+ groups = m.groupdict(0)
+ return type_(**dict(zip(groups.iterkeys(),
+ map(int, groups.itervalues()))))
+ else:
+ return type_(*map(int, m.groups(0)))
return process
def boolean_to_int(value):