title: Sqlalchemy duplicate entry
body: <p>I have the following code:</p>
  
  <pre><code>    purchased_offer = session.query(PurchasedOffer).filter_by(purchased_offer_id=purchased_offer_id).first()
      used_offer = UsedOffer(purchased_offer)
      session.add(used_offer)
      session.delete(purchased_offer)
  </code></pre>
  
  <p>I am just transferring the <code>purchased_offer</code> to the <code>used_offer</code> table and then deleting <code>purchased_offer</code>.</p>
  
  <p>The two tables <code>UsedOffer</code> and <code>PurchasedOffer</code> only differ by name and are identical with regards to content. </p>
  
  <pre><code>class UsedOffer(Base):
  __tablename__ = 'used_offer'
  
  used_offer_id = Column(Integer, primary_key=True)
  user_id = Column(ForeignKey(u'user.user_id'), nullable=False, index=True)
  venue_id = Column(ForeignKey(u'venue.venue_id'), nullable=False, index=True)
  offer_message = Column(String(1024), nullable=False)    
  
  user = relationship(u'User')
  venue = relationship(u'Venue')
  
  def __init__(self, purchased_offer):
      self.user_id = purchased_offer.user_id
      self.venue_id = purchased_offer.venue_id
      self.offer_message = purchased_offer.offer_message
  
  class PurchasedOffer(Base):
      __tablename__ = 'purchased_offer'
  
      purchased_offer_id = Column(Integer, primary_key=True)
      user_id = Column(ForeignKey(u'user.user_id'), nullable=False, index=True)
      venue_id = Column(ForeignKey(u'venue.venue_id'), nullable=False, index=True)
      offer_message = Column(String(1024), nullable=False)   
  
      user = relationship(u'User')
      venue = relationship(u'Venue')
  
      def __init__(self, user_id = None, venue_id = None, offer_message = None):
          self.user_id = user_id
          self.venue_id = venue_id
          self.offer_message = offer_message      
  </code></pre>
  
  <p>My problem is that when I add <code>used_offer</code> to the <code>database</code>, the <code>used_offer_id</code> is always set to <code>0</code> so when I go through this process a <code>2nd</code> time, I get a <code>duplicate error</code>.</p>
  
  <p>Anyone have any ideas as to why this might be happening?</p>