Issue 1:
Migrated issue, originally created by Anonymous

func.max and func.min do not convert result object to correct datetime object.

---testcase.py

import sqlalchemy as sqa
import datetime

db = sqa.create_engine("sqlite://")
metadata = sqa.BoundMetaData(db)

#metadata.engine.echo = True # debug output

events_table = sqa.Table('events', metadata,
sqa.Column('id', sqa.Integer, primary_key=True),
sqa.Column('name', sqa.String(255)),
sqa.Column('datetime', sqa.DateTime),
)
events_table.create()

i = events_table.insert()
name = "just-a-name"
i.execute(name = name, datetime = datetime.datetime(2007, 7, 26, 10, 23, 44))
i.execute(name = name, datetime = datetime.datetime(2007, 7, 26, 12, 43, 44))
i.execute(name = name, datetime = datetime.datetime(2007, 7, 26, 17, 23, 34))
i.execute(name = name, datetime = datetime.datetime(2007, 7, 26, 22, 54, 23))
i.execute(name = name, datetime = datetime.datetime(2007, 7, 26, 23, 00, 18))

date = "2007-07-26"
test1 = sqa.select(
[events_table.c.datetime](events_table.c.datetime),
(sqa.func.date(events_table.c.datetime) == date) &
(events_table.c.name == name)
).execute().fetchone()
print "--"
print test1
print type(test1)
print type(test1[0](0))
print "-"
test2 = sqa.select(
[sqa.func.max(events_table.c.datetime)](sqa.func.max(events_table.c.datetime)),
(sqa.func.date(events_table.c.datetime) == date) &
(events_table.c.name == name)
).execute().fetchone()
print test2
print type(test2)
print type(test2[0](0))

---output

(datetime.datetime(2007, 7, 26, 10, 23, 44),)
<class 'sqlalchemy.engine.base.RowProxy'>
<type 'datetime.datetime'>
-
(u'2007-07-26 23:00:18.0',)
<class 'sqlalchemy.engine.base.RowProxy'>
<type 'unicode'>

Attachments: testcase.py

Issue 2:
Migrated issue, originally created by Anonymous

As posted here: http://groups.google.com/group/sqlalchemy/browse_thread/thread/d4c0f163f1f414e4

When you do a multiple-row insert, such as:

users.insert().execute(

{'user_id':6, 'user_name':'jack', 'password':'asdfasdf'},

{'user_id':7, 'user_name':'ed'},

{'user_id':8, 'user_name':'scott', 'password':'fadsfads'},

{'user_id':9, 'user_name':'bob'},

)

...the 'password' field for the second and fourth rows, rather than

being set to None or raising an error, take the first row's password

value.

While it is somewhat slack not to provide all the columns for each

row, SA shouldn't really duplicate the first row's values, nei?

thats actually a huge pain in the butt to fix because there is an

implicit behavior behind:

`users.insert().execute({'a':1, 'b':2, 'c'3}, {<dict2>}, {<dict3>}, ...) `

in that its the same as saying:

`users.insert(values={'a':1, 'b':2, 'c'3}).execute({'a':1, 'b':2, 'c'3}, {<dict2>}, {<dict3>}, ...) `

i.e. the statement is compiled against the parameters in the first

element of execute arguments. so they take place for subsequent

execute arguments that dont override them.

awareness would have to be added to ClauseElement/ANSICompiler to

differentiate between compiled-in parameters and compiled-in

parameters that came from execute params, and compiled.get_params()

would have to check the incoming params against the original execute-

params and raise an error if keys dont match.

Mel C