[sqlalchemy] Re: Suggestions for abbreviations

2009-01-11 Thread Andreas Jung
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 11.01.2009 12:13 Uhr, Cito wrote:
 I wonder why declarative_base() doesn't simply set __tablename__ to
 the name of the class by default (maybe translating camelcase to
 lowercase with underscores).


Please no implicit magic under the hood. You can have multiple mappers
for the same table. Citing Guido: explicit is better than implicit.

My-2-cent,
Andreas
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAklp16AACgkQCJIWIbr9KYzroQCgxVi70Tb7Bf+qMd5uRcrfbNtf
+sEAnjRkrmhGjyt18Igv5f3RacGjDkzD
=ibCE
-END PGP SIGNATURE-

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---

begin:vcard
fn:Andreas Jung
n:Jung;Andreas
org:ZOPYX Ltd.  Co. KG
adr;quoted-printable:;;Charlottenstr. 37/1;T=C3=BCbingen;;72070;Germany
email;internet:i...@zopyx.com
title:CEO
tel;work:+49-7071-793376
tel;fax:+49-7071-7936840
tel;home:+49-7071-793257
x-mozilla-html:FALSE
url:www.zopyx.com
version:2.1
end:vcard



[sqlalchemy] Re: Suggestions for abbreviations

2009-01-11 Thread Christoph Zwerschke

Andreas Jung schrieb:
 Please no implicit magic under the hood. You can have multiple mappers
 for the same table. Citing Guido: explicit is better than implicit.

You wouldn't be forced to use that magic, you could still set 
__tablename__ explictly. I understand your argument, but otoh beautiful 
is better than ugly outplays explicit is better than implicit ;-)

-- Christoph

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: Suggestions for abbreviations

2009-01-11 Thread Michael Bayer


On Jan 11, 2009, at 6:13 AM, Cito wrote:


 I wonder why declarative_base() doesn't simply set __tablename__ to
 the name of the class by default (maybe translating camelcase to
 lowercase with underscores), similar to how it is done in SQLObject
 and Elixir. Also, the error message if you forget to set __tablename__
 is misleading, it should mention __tablename__ in declarative usage.

__tablename__ is optional in the sense that you could alternatively  
specify __table__, or if you inherit then the table is optional  
entirely since you're using single table inheritance.  I have heard  
the error message is misleading so we should fix that.

As far as implicit tablename, it breaks the single inheritance  
scenario.  but also besides that I made a comment on that here:

http://www.sqlalchemy.org/trac/ticket/1270#comment:2

 Another idea (not sure if it really makes sense): In the order_by
 clause, negative integers could be used for descending order, i.e. -2
 would work like desc(2).

im not actually familiar with that technique ?  does that mean ORDER  
BY 2 DESC or ORDER BY somecolumn DESC(2) ?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: Suggestions for abbreviations

2009-01-11 Thread Christoph Zwerschke

Michael Bayer schrieb:
 As far as implicit tablename, it breaks the single inheritance  
 scenario.  but also besides that I made a comment on that here:
 
 http://www.sqlalchemy.org/trac/ticket/1270#comment:2

Thanks, I hadn't seen that. Not quite sure what you mean with single 
inheritance scenario, though.

 Another idea (not sure if it really makes sense): In the order_by
 clause, negative integers could be used for descending order, i.e. -2
 would work like desc(2).
 
 im not actually familiar with that technique ?  does that mean ORDER  
 BY 2 DESC or ORDER BY somecolumn DESC(2) ?

Very simple, the former:

session.query(Foo).order_by(-2)

should work the same as

from sqlalchemy import desc
session.query(Foo).order_by(desc(2))

The idea is that it's somewhat shorter and intuitive since for names of 
numerical columns, you also get reverse order if you add a minus sign.

-- Christoph

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: Suggestions for abbreviations

2009-01-11 Thread Michael Bayer


On Jan 11, 2009, at 11:06 AM, Christoph Zwerschke wrote:


 Michael Bayer schrieb:
 As far as implicit tablename, it breaks the single inheritance
 scenario.  but also besides that I made a comment on that here:

 http://www.sqlalchemy.org/trac/ticket/1270#comment:2

 Thanks, I hadn't seen that. Not quite sure what you mean with single
 inheritance scenario, though.

if Bar inherits from Foo, Foo is mapped to foo_table, Bar has no  
table, Bar will be mapped to foo_table as well.

 Very simple, the former:

 session.query(Foo).order_by(-2)

 should work the same as

 from sqlalchemy import desc
 session.query(Foo).order_by(desc(2))

 The idea is that it's somewhat shorter and intuitive since for names  
 of
 numerical columns, you also get reverse order if you add a minus sign.

oh, this is entirely news to me that you can send column positions to  
ORDER BY.  SQLA has no awareness of that concept right now.   seems  
like more than one way to do it at the moment...(i.e. order by  
columns *or* position, times use desc or negation == 4 ways).

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: Suggestions for abbreviations

2009-01-11 Thread Christoph Zwerschke

Michael Bayer schrieb:
 if Bar inherits from Foo, Foo is mapped to foo_table, Bar has no  
 table, Bar will be mapped to foo_table as well.

In that case, no implicit name should be set or course. It should only 
be set if a name cannot be figured out otherwise.

 oh, this is entirely news to me that you can send column positions to  
 ORDER BY.  SQLA has no awareness of that concept right now.   seems  
 like more than one way to do it at the moment...(i.e. order by  
 columns *or* position, times use desc or negation == 4 ways).

Using column positions is a standard SQL feature AFAIK (i.e. positive 
indices; using negative indices for reverse order was my idea only) and 
it also seems to works perfectly well with SQLAlchemy :)

Since the only one way principle is broken here anyway, I thought 
adding another shortcut will not harm...

-- Christoph

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: Suggestions for abbreviations

2009-01-11 Thread Michael Bayer


On Jan 11, 2009, at 11:41 AM, Christoph Zwerschke wrote:


 Michael Bayer schrieb:
 if Bar inherits from Foo, Foo is mapped to foo_table, Bar has no
 table, Bar will be mapped to foo_table as well.

 In that case, no implicit name should be set or course. It should only
 be set if a name cannot be figured out otherwise.

a lot of people have complained about the message, and it is this:

ArgumentError: Mapper 'Mapper|User|None' does not have a mapped_table  
specified.  (Are you using the return value of table.create()?  It no  
longer has a return value.)

That's a really old error message, and I can see how its less than  
perfect so I've just changed it and added a declarative specific  
message which supercedes it, so the issue is resolved.  But I don't  
see how the old message is *confusing*.  It seems obvious that its  
saying no table is present to be mapped, what else could it possibly  
mean ?



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: Suggestions for abbreviations

2009-01-11 Thread Christoph Zwerschke

Michael Bayer schrieb:
 ArgumentError: Mapper 'Mapper|User|None' does not have a mapped_table  
 specified.  (Are you using the return value of table.create()?  It no  
 longer has a return value.)
 
 That's a really old error message, and I can see how its less than  
 perfect so I've just changed it and added a declarative specific  
 message which supercedes it, so the issue is resolved.  But I don't  
 see how the old message is *confusing*.  It seems obvious that its  
 saying no table is present to be mapped, what else could it possibly  
 mean ?

Thanks. Well, the message was not really confusing, only misleading in 
that it says you need to specify mapped_table where you actually need 
to specify __table__ or __tablename___.

-- Christoph

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---