mistercrunch commented on a change in pull request #4746: Filtering out SQLLab views out of table list view by default URL: https://github.com/apache/incubator-superset/pull/4746#discussion_r179346252
########## File path: superset/migrations/versions/130915240929_is_sqllab_viz_flow.py ########## @@ -0,0 +1,54 @@ +"""is_sqllab_view + +Revision ID: 130915240929 +Revises: f231d82b9b26 +Create Date: 2018-04-03 08:19:34.098789 + +""" +from alembic import op +import sqlalchemy as sa +from sqlalchemy.ext.declarative import declarative_base + +from superset import db + +# revision identifiers, used by Alembic. +revision = '130915240929' +down_revision = 'f231d82b9b26' + +Base = declarative_base() + + +class Table(Base): + """Declarative class to do query in upgrade""" + __tablename__ = 'tables' + id = sa.Column(sa.Integer, primary_key=True) + sql = sa.Column(sa.Text) + is_sqllab_view = sa.Column(sa.Boolean()) + + +def upgrade(): + bind = op.get_bind() + op.add_column( + 'tables', + sa.Column( + 'is_sqllab_view', + sa.Boolean(), + nullable=True, + default=False, + server_default=sa.false(), + ), + ) + + session = db.Session(bind=bind) + + # Use Slice class defined here instead of models.Slice + for tbl in session.query(Table).all(): + if tbl.sql: + tbl.is_sqllab_view = True Review comment: Right, I'm not sure how else to identify it. It's the best proxy we have. Note that this does not change any behavior other than being filtered out by default in the Table list view, but the filter can be removed anyways, so I didn't think it had to be perfect. Goal here is just to hide some of the clutter this creates. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
