Skip to content

Add columns with secret=True parameter to Table._meta.secret_columns #918

Description

@patrickneise

In working with PydanticDTO from litestar, realized that columns with secret=True parameter were not being added to Table._meta.secret_columns

Seems like a relatively small change:

# piccolo/table.py

# line 85 -> update type from Secret to Column to support any Column type as secret_column
secret_columns: t.List[Column] = field(default_factory=list)

# line 271 -> update type from Secret to Column any Column type as secret_column
secret_columns: t.List[Column] = []

# line 311 -> add check for secret param
if isinstance(column, Secret) or column._meta.secret:
    secret_columns.append(column)

With new test:

# tests/table/test_metaclass.py
def test_secret_columns_with_param(self):
    """
    Make sure TableMeta.secret_columns include columns with `secret=True`
    """

    class Classified(Table):
        top_secret = Varchar(secret=True)

    self.assertEqual(
        Classified._meta.secret_columns, [Classified.top_secret]

Changes staged for PR here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions