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

JSON Array Field #131

Merged
merged 11 commits into from
Mar 24, 2021
Merged

JSON Array Field #131

merged 11 commits into from
Mar 24, 2021

Conversation

andy-wm-arthur
Copy link
Contributor

Replaces uses of Postgres array fields with a custom JSON array field

@andy-wm-arthur andy-wm-arthur marked this pull request as ready for review March 11, 2021 03:31
nautobot/dcim/lookups.py Outdated Show resolved Hide resolved
nautobot/utilities/testing/views.py Outdated Show resolved Hide resolved
nautobot/utilities/forms/fields.py Show resolved Hide resolved
nautobot/utilities/fields.py Show resolved Hide resolved
nautobot/dcim/fields.py Show resolved Hide resolved
nautobot/utilities/fields.py Outdated Show resolved Hide resolved
nautobot/utilities/fields.py Outdated Show resolved Hide resolved
nautobot/utilities/fields.py Outdated Show resolved Hide resolved
nautobot/utilities/fields.py Outdated Show resolved Hide resolved
nautobot/utilities/forms/fields.py Outdated Show resolved Hide resolved
nautobot/utilities/forms/fields.py Outdated Show resolved Hide resolved
nautobot/utilities/testing/views.py Show resolved Hide resolved
nautobot/utilities/forms/fields.py Show resolved Hide resolved
Copy link
Contributor

@glennmatthews glennmatthews left a comment

Choose a reason for hiding this comment

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

Nearly there, thanks!

nautobot/utilities/fields.py Outdated Show resolved Hide resolved
nautobot/utilities/fields.py Outdated Show resolved Hide resolved
nautobot/utilities/forms/fields.py Outdated Show resolved Hide resolved
Copy link
Contributor

@glennmatthews glennmatthews left a comment

Choose a reason for hiding this comment

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

Nice work!

nautobot/dcim/lookups.py Show resolved Hide resolved
Copy link
Contributor

@jathanism jathanism left a comment

Choose a reason for hiding this comment

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

We've arrived at me nitpicking docstrings. I am super pleased with this and as far as I'm concerned, these are my last pieces of feedback on this PR. :)

nautobot/dcim/tests/test_cablepaths.py Show resolved Hide resolved
nautobot/utilities/fields.py Outdated Show resolved Hide resolved
"""
A FormField counterpart to JSONArrayField.
Replicates ArrayFormField's base field validation: Field values are validated as JSON Arrays,
and each Array element is validated by |base_field| validators.
Copy link
Contributor

Choose a reason for hiding this comment

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

If you could sub the |foo| pipes w/ backticks here in this class, too, please.

Copy link
Contributor

@glennmatthews glennmatthews left a comment

Choose a reason for hiding this comment

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

Thank you!

@@ -45,6 +45,9 @@ def setUpTestData(cls):
cls.status = cls.statuses.get(slug="connected")
cls.status_planned = cls.statuses.get(slug="planned")

# create a Cable that is not contained in any CablePath
cls.dneCable = Cable(status=cls.status)
Copy link
Contributor

Choose a reason for hiding this comment

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

is this being created intentionally as an invalid object? Normally the Cable terminations are required to be non-null and are checked for validity in the Cable.clean() method.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it's the "does not exist cable". It's used in assertContainedByPath() to assert that path_contains is not returning false positives. Attempting to .clean() or .save() this Cable will fail, but it's valid to use it in filter expressions

@jathanism jathanism merged commit dbb34c0 into nautobot:develop Mar 24, 2021
@andy-wm-arthur andy-wm-arthur deleted the andy/json-array branch March 24, 2021 20:43
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

Successfully merging this pull request may close these issues.

None yet

3 participants