you generally shouldnt store any "information" in a primary key.  primary
keys are by definition immutable so SA would likely trip up if you change
them.  its conceivable that a feature could be added to allow updating the
primary key columns but it would add a lot of complexity to the saving
mechanism, to support a pattern that generally is not really correct.

http://en.wikipedia.org/wiki/Primary_key


if you want an extra "check for this condition" step its not totally
impossible, although i dont know if I want to add assertions throughout
the code for things like this since it will eventually chunk down the
performance.  feel free to add a ticket to Trac for a "check that primary
key columns havent changed, raise exception" feature, id have to consider
how non-intrusive that is.


Sandro Dentella wrote:
>
> I resend this message, as it got unanswered...
> Thanks
> sandro
> *:-)
>
>
>   It took me some time to understand that you can't UPDATE a primary key
> using
>   the mapper. Is there a way to bypass this restriction? Am I understandig
> it
>   correctly? Is there a way to understand that some UPDATE where not
>   commmitted becouse of this restriction? I'd think it should raise and
> exception...
>
>   TIA
>   sandro
>
>
> eng = create_engine("sqlite://", echo=False)
>
> users = Table('users', eng,
>        Column('user_name', String(30), nullable = False, primary_key =
> True),
>        Column('user_last_name', String(30), nullable = False))
>
> users.create()
>
> users.insert().execute(
>     {'user_name': 'Sam', 'user_last_name': 'Patts'},
>     {'user_name': 'Sid', 'user_last_name': 'Watts'},
>
> class User(object): pass
>
> m = mapper(User, users)
> u = m.select()[1]
>
> eng.echo = True
>
> u.user_name = 'Sandro'
> objectstore.commit()
>
> --
> Sandro Dentella  *:-)
> e-mail: [EMAIL PROTECTED]
> http://www.tksql.org                    TkSQL Home page - My GPL work
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by xPML, a groundbreaking scripting
> language
> that extends applications into web and mobile media. Attend the live
> webcast
> and join the prime developer group breaking into this new coding
> territory!
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
> _______________________________________________
> Sqlalchemy-users mailing list
> Sqlalchemy-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users
>



-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Sqlalchemy-users mailing list
Sqlalchemy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users

Reply via email to