Merge "Use with_variant method for dialects db types"

This commit is contained in:
Jenkins 2014-07-30 17:31:19 +00:00 committed by Gerrit Code Review
commit d794d08302
2 changed files with 4 additions and 9 deletions

View File

@ -24,6 +24,7 @@ from sqlalchemy import orm as sa_orm
from murano.common import uuidutils from murano.common import uuidutils
from murano.db import session as db_session from murano.db import session as db_session
from murano.db.sqla import types as st
from murano.openstack.common import timeutils from murano.openstack.common import timeutils
@ -265,7 +266,7 @@ class Package(BASE, ModificationsTrackedObject):
id = sa.Column(sa.String(36), id = sa.Column(sa.String(36),
primary_key=True, primary_key=True,
default=uuidutils.generate_uuid) default=uuidutils.generate_uuid)
archive = sa.Column(sa.LargeBinary) archive = sa.Column(st.LargeBinary())
fully_qualified_name = sa.Column(sa.String(512), fully_qualified_name = sa.Column(sa.String(512),
nullable=False, nullable=False,
index=True, index=True,
@ -283,7 +284,7 @@ class Package(BASE, ModificationsTrackedObject):
secondary=package_to_tag, secondary=package_to_tag,
cascade='save-update, merge', cascade='save-update, merge',
lazy='joined') lazy='joined')
logo = sa.Column(sa.LargeBinary, nullable=True) logo = sa.Column(st.LargeBinary(), nullable=True)
owner_id = sa.Column(sa.String(36), nullable=False) owner_id = sa.Column(sa.String(36), nullable=False)
ui_definition = sa.Column(sa.Text) ui_definition = sa.Column(sa.Text)
supplier_logo = sa.Column(sa.LargeBinary, nullable=True) supplier_logo = sa.Column(sa.LargeBinary, nullable=True)

View File

@ -17,11 +17,5 @@ from sqlalchemy.dialects import mysql
CONF = cfg.CONF CONF = cfg.CONF
def _is_mysql_avail():
return CONF.database.connection.startswith('mysql')
def LargeBinary(): def LargeBinary():
if _is_mysql_avail(): return sa.LargeBinary().with_variant(mysql.LONGBLOB(), 'mysql')
return mysql.LONGBLOB
return sa.LargeBinary