Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
patrickneise opened this issue Jan 10, 2024 · 1 comment
Open

Comments

@patrickneise
Copy link

patrickneise commented Jan 10, 2024

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.

@dantownsend
Copy link
Member

Sorry for the slow response on this. I was mulling over what to do.

I think your changes makes perfect sense - if you can open a PR, I'll merge it in. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants