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

430 Fix bug with optional fields in custom forms #432

Merged
merged 14 commits into from
Jan 16, 2025

Conversation

dantownsend
Copy link
Member

Related to #430

@dantownsend dantownsend added the bug Something isn't working label Jan 14, 2025
@@ -9,7 +9,7 @@ on:
jobs:
playwright:
name: "Playwright Tests"
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like Playwright isn't running out of the box on Ubuntu 24.04 at the moment due to some missing dependencies.

microsoft/playwright#30368

We need the latest version to get around a breaking change in Starlette's test client:

encode/starlette#2770
I'm pretty sure the type annotations on Starlette are wrong - passing a HTTPEndpoint in should be allowed.
@@ -680,7 +680,7 @@ def __init__(

private_app.add_route(
path="/change-password/",
route=change_password(
route=change_password( # type: ignore
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm pretty sure the Starlette type annotations are wrong here - we're just passing in a HTTPEndpoint.

@@ -786,7 +786,7 @@ def __init__(

public_app.add_route(
path="/logout/",
route=session_logout(session_table=session_table),
route=session_logout(session_table=session_table), # type: ignore
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above about type annotations.

// TODO We can potentially remove this in the future - isNullable does
// what we need.
value = null
} else if (isNullable(property) && value == "") {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is problematic with the current version of Piccolo - in the Pydantic model for tables, they default to optional, unless required=True.

This PR fixes it:

piccolo-orm/piccolo#1141

But need to decide whether it's a good idea or not.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really understand what the implication here is, maybe @sinisaos has some thoughts?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks both for testing it.

I'll change this slightly, so it's completely backwards compatible - i.e. the current behaviour for tables, and for custom forms it uses isNullable.

Copy link
Contributor

@Skelmis Skelmis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested, lgtm

@sinisaos
Copy link
Member

I also tested this PR against the latest Piccolo ORM PR and in my opinion everything works fine.

@dantownsend
Copy link
Member Author

I made this backwards compatible, so it doesn't require any changes to create_pydantic_model - it gives us some more time to think it through. Thanks both!

@dantownsend dantownsend merged commit 7676b55 into master Jan 16, 2025
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Closed
Development

Successfully merging this pull request may close these issues.

3 participants