Hi all,
I can't wrap my mind around a problem of naming mapped classes. Here
is an example to explain what is going on.
Suppose I have a table in the database called "comments". Now I have
two choices how to call the class that will represent "comments".
Either "class Comments" in plural, or "class Comment" in singular.
If I name the class in plural, "class Comments", then a query like:
Session.add(Comments("a new comment"))
sounds weird. I am adding a new comment but using plural to refer to
it "I am adding a new Comments". Which is just weird.
The other possibility is to use singular, "class Comment". That fixes
the above problem but introduces a new problem, particularly,
Session.query(Comment).all()
But now I am querying singular expression "get all comment" to get
plural out. My mind refuses to understand that.
Anyone else has the same issues on naming things?
I am thinking the workaround is to introduce aliases, "Comment" and
"Comments" and use them where necessary:
Session.add(Comment("a new comment"))
and
Session.query(Comments).all()
where both Comment and Comments refer to the same table.
Sincerely,
Peteris Krumins
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en.