Hello Gang,
I am trying to create a related join with a creation date. After
digging on google. I found an example looking a little bit like that.
class Tags(SQLObject):
term = UnicodeCol(length=64, alternateID=True,
alternateMethodName='by_term')
articles = SQLRelatedJoin("Article",
intermediateTable="article_tag",
createRelatedTable=False,
joinColumn="tag_id", otherColumn="article_id")
class ArticleTag(SQLObject):
class sqlmeta:
table = "article_tag"
article = ForeignKey('Article', notNull=True, cascade=True)
tag = ForeignKey('Tags', notNull=True, cascade=True)
created = DateTimeCol(default=datetime.now)
unique = index.DatabaseIndex(article, tag, unique=True)
The problem is that when the record is created for the table
article_tag the created field is not set to the default. Is there
something obvious I am missing or is what am am doing not possible ?
>>> a = Article.get(139)
>>> list(a.tags)
[]
>>> t=Tags(term='foobar')
>>> t.addArticle(a)
1/Query : INSERT INTO article_tag (tag_id, article_id) VALUES
(929, 139)
1/QueryR : INSERT INTO article_tag (tag_id, article_id) VALUES
(929, 139)
>>>
>>> # the insert doesn't include the field "created"
>>>
>>> for at in ArticleTag.selectBy(articleID=139):
... print at
...
1/Select : SELECT article_tag.id, article_tag.article_id,
article_tag.tag_id, article_tag.created FROM article_tag WHERE
article_id = 139
1/QueryR : SELECT article_tag.id, article_tag.article_id,
article_tag.tag_id, article_tag.created FROM article_tag WHERE
article_id = 139
<ArticleTag 1461 articleID=139 tagID=929 created=None>
>>>
Thanks for your suggestions.
-fred-
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss