Now I encounter a duplicate id bug.
Caused by Id generate like this :

FormulaElement.query.count() + 1

Once delete some elements from table, there will be some duplicate id.
I have have to use autoincrement flag
But however, autoincrement flag does not work when there is more than
two primary key as I mentioned.

Or another choice, I have to set another primary-key to non-primary-
key.

How to solve this problem?
Thanks.

On 8月25日, 下午9時13分, Victor Lin <[EMAIL PROTECTED]> wrote:
> On 8月25日, 下午7時15分, "Gaetan de Menten" <[EMAIL PROTECTED]> wrote:> On Sat, Aug 
> 23, 2008 at 2:15 PM, Victor Lin <[EMAIL PROTECTED]> wrote:
>
> > > Formula pattern is release now.
>
> > >http://elixir.ematia.de/trac/wiki/Recipes/Formula
>
> > Thanks for sharing! I'm skimmed through it and I have a few comments:
>
> > Could you translate the Chinese text in the examples to English? It
> > usually makes for more understandable examples (to those who can't
> > read Chinese). Besides, some people don't even have chinese fonts
> > installed, so all they see it some ugly rectangle characters.
>
> Ok, I will translate that when I was free.
>
>
>
> > I notice you defined several toString methods on your classes. Why
> > didn't you use Python's builtin __str__ ? so that you can simply
> > "print <a formula>" ?
>
> I do it before, but I have some problem to display some class in
> __repr__
> They will looks like
>
> <XXXX 1 of (10 + 3) / 4>
>
> I think I should replace "%s" to "%r", rather than create such thing
> like "toString".
> Thank your comment.
>
> > Finally, in FormulaElement, you manually define some kind of sequence.
> > Why is it so? Why don't you let the "id" column be generated
> > automatically and use the default sequence for it?
>
> > FormulaElement(Entity):
> >     using_options(inheritance='multi')
> >     using_options(tablename='formula_element')
>
> >     id = Field(Integer, primary_key=True, default=getNextId)
> >     ...
>
> I'd like to do so, but there is some strange problem. It seems that
> "autoincrement" doesn't work at table which have multi-primarykey.
> I just write some code to reduce this problem.
>
> from elixir import *
>
> metadata.bind = 'sqlite:///'
> metadata.bind.echo = True
>
> class Director(Entity):
>     name = Field(Unicode(60))
>
>     def __repr__(self):
>         return '<Director "%s">' % self.name
>
> class Movie(Entity):
>     id = Field(Integer, primary_key=True, autoincrement=True)
>     director = ManyToOne('Director', primary_key=True)
>     title = Field(Unicode(30))
>
>     def __repr__(self):
>         return '<Movie "%s" (%d)>' % (self.title, self.year)
>
> setup_all(True)
>
> noName = Director(name='No Name')
> newMovie = Movie(title='hello world')
> session.commit()
>
> Here comes the error:
> sqlalchemy.exc.IntegrityError: (IntegrityError) __main___movie.id may
> not be NULL u'INSERT INTO __main___movie (title) VALUES (?)' ['hello
> world']
>
> I think it is a SQL feature, so I didn't ask in group or report it.
> Is this a SQL feature? Or what am I doing wrong?
>
> Thanks.
>
>
>
> > > By the way, I update a file "test_formula_builder.2.py" that is
> > > duplicate, but I have no idea how to delete it, could someone delete
> > > it for me? Thanks.
>
> > Done.
>
> > --
> > Gaëtan de Mentenhttp://openhex.org
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"SQLElixir" 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/sqlelixir?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to