title: Flask-SQLAlchemy db.commit() changes value of field
body: <p>I'm building a simple app in Flask and having difficulty with making the database behave properly while using Flask-SQLAlchemy.  Here's my models.py:</p>
  
  <pre><code>from spot import plate
  from spot import db
  import flask.ext.whooshalchemy as whooshalchemy
  
  class Country(db.Model):
      id = db.Column(db.Integer, primary_key = True)
      country_name = db.Column(db.String(64), unique = True)
      codes = db.relationship('Code', backref='country', lazy='dynamic')
  
      def __repr__(self):
          return '&lt;%r&gt;' % (self.country_name)
  
  class Code(db.Model):
      __searchable__ = ['scramble']
  
      id = db.Column(db.Integer, primary_key = True)
      scramble = db.Column(db.String(64), db.ForeignKey('country.id'))
  
      def __repr__(self):
          return '&lt;%r&gt;' % (self.scramble)
  
  whooshalchemy.whoosh_index(plate, Code)
  </code></pre>
  
  <p>I'm trying to create some test data to see if the relationship works as I expect it to, but for some reason, when I create a new Code and commit it to the database, something is overwriting the value of my scramble field to "1", as follows:</p>
  
  <pre><code>&gt;&gt;&gt; from spot.models import Country, Code 
  &gt;&gt;&gt; from spot import db
  &gt;&gt;&gt; c = Country(country_name="Testingstan")
  &gt;&gt;&gt; cd = Code(scramble="TS", country=c)
  &gt;&gt;&gt; cd.scramble
  'TS'
  &gt;&gt;&gt; db.session.add(c)
  &gt;&gt;&gt; c.country_name
  'Testingstan'
  &gt;&gt;&gt; db.session.add(cd)
  &gt;&gt;&gt; cd.scramble
  'TS'
  &gt;&gt;&gt; db.session.commit()
  &gt;&gt;&gt; c.country_name
  u'Testingstan'
  &gt;&gt;&gt; cd.scramble
  u'1'
  &gt;&gt;&gt; for code in c.codes:
  ...     print code
  ...
  &lt;u'1'&gt;
  </code></pre>
  
  <p>So I'm feeling confident that the association between the country and the code is being made properly, but why is SQLAlchemy overwriting my scrambles but not my country name?  I pulled up the database in a sqlite database browser, and it's showing me the same thing.  What have I set up incorrectly?</p>