- changed status to resolved
enum using old event system/ PG hardcoding "checkfirst"
Issue #2311
resolved
class Test(db.Model):
__tablename__ = 'test'
id = db.Column(db.Integer, primary_key=True)
birthday = db.Column(db.Date)
gender = db.Column(db.Enum('male', 'female', name='TYPE_GENDER'))
relationship_status = db.Column(db.Enum('free', 'in_relationship',
'married', 'complicated', 'in_open_relationship', 'widowed',
name='TYPE_RELATION'))
relationship_user_id = db.Column(db.Integer,
db.ForeignKey('test.id'))
relationship_user = db.relationship('Test',
backref=db.backref('parent', remote_side=id))
religion_id = db.Column(db.Integer, db.ForeignKey('religion.id'))
religion = db.relationship('Religion', backref=db.backref('user'),
cascade='all, delete, delete-orphan')
from sqlalchemy import *
from StringIO import StringIO
buf = StringIO()
pg_engine = create_engine('sqlite://', strategy='mock',
executor=lambda s,p=';': buf.write(s.__str__() + p))
buf.truncate(0)
tables = [x[1](x[1) for x in sorted(db.metadata.tables.items(), key=lambda
x: x[0](0))]
for table in tables:
table.create(pg_engine)
print buf.getvalue()
ok, it prints,
but if I change engine to 'postgres://'
/usr/lib/python2.7/site-packages/sqlalchemy/types.pyc in
_on_table_create(self, event, target, bind, **kw)
1676 t = self.dialect_impl(bind.dialect)
1677 if t.__class__ is not self.__class__ and isinstance(t,
SchemaType):
-> 1678 t._on_table_create(event, target, bind, **kw)
1679
1680 def _on_table_drop(self, event, target, bind, **kw):
/usr/lib/python2.7/site-packages/sqlalchemy/dialects/postgresql/
base.pyc in _on_table_create(self, event, target, bind, **kw)
451
452 def _on_table_create(self, event, target, bind, **kw):
--> 453 self.create(bind=bind, checkfirst=True)
454
455 def _on_metadata_create(self, event, target, bind, **kw):
/usr/lib/python2.7/site-packages/sqlalchemy/dialects/postgresql/
base.pyc in create(self, bind, checkfirst)
439
440 if not checkfirst or \
--> 441 not bind.dialect.has_type(bind, self.name,
schema=self.schema):
442 bind.execute(CreateEnumType(self))
443
Comments (2)
-
reporter -
reporter - removed milestone
Removing milestone: 0.7.4 (automated comment)
- Log in to comment
e6a5ea8fa7d10078c8d3f1bf6cabc4399cac3e70