Commit Graph

21 Commits

Author SHA1 Message Date
Jason Novinger 9782be4cd5 Assert the collation reaches the query, and clarify the documented behaviour
The existing tests assert on filter results, which stay correct for ASCII values
even when the collation is never applied. Add a test which asserts on the
lookup's own compiled output, so that the mechanism failing open is caught
rather than passing silently.

Explain why the placeholder is compared literally: a field declaring its own
get_placeholder() compiles to something other than '%s', and splicing a COLLATE
clause into that is not safe, so any other right-hand side is left alone.

The documentation note described the folding as specific to the German
eszett. It is the common example rather than the rule: the collation treats a
character as equivalent to the sequence it expands to in upper case, which also
covers ligatures. Note too that a case-insensitive exact match on a collated
field may now return more than one object.
2026-09-11 03:50:47 -05:00
Jason Novinger 2769e3d9d9 Fixes #23012: Respect column collation when filtering case-insensitively
Django's PostgreSQL backend compiles icontains, iexact, istartswith and
iendswith as UPPER(col::text) LIKE UPPER(%s). UPPER() folds according to the
collation of its argument, and the two sides do not share one: the column folds
under its own collation while the parameter folds under the database default.

For a column using natural_sort, UPPER('ß') is 'SS' on the left and 'ß' on the
right, so searching for 'ß' matched nothing. This affects the name field of most
models and all four case-insensitive lookups, which are also exposed through the
REST API as __ic, __ie, __isw and __iew.

Apply the column's collation to the parameter as well, inside the UPPER() call,
so that both sides fold the same way. Matching on those fields becomes
bidirectional, so 'Strasse' finds 'Straße' and vice versa. Fields without the
collation are unchanged.

The lookups only collate a bare column compared against a simple value. An
expression which already carries an explicit collation, such as Collate() or
CollateAsChar(), would otherwise raise a collation mismatch error.
2026-09-11 03:18:31 -05:00
Jeremy Stretch 9abbebe392 Add v4.7 release notes 2026-08-14 13:53:02 -04:00
Jeremy Stretch ca76dacbf3
#18159: Handle malformed paths and absent data in conditions (Pre-release QA) (#22911)
Distinguish absent values from malformed or unwalkable paths during
condition evaluation.

Preserve valid empty-list traversal, support changes in snapshot shape,
and reject snapshot attributes which are missing from both snapshots.

Normalize absent job payloads and ensure conditioned rules fail closed
when no payload is available. Add regression coverage and streamline the
related documentation and comments.
2026-08-14 10:09:05 +02:00
Jeremy Stretch d2df19790f Merge branch 'main' into feature
# Conflicts:
#	contrib/openapi.json
#	docs/release-notes/version-4.6.md
#	netbox/dcim/choices.py
#	netbox/dcim/forms/mixins.py
#	netbox/dcim/models/device_component_templates.py
#	netbox/dcim/models/device_components.py
#	netbox/extras/dashboard/widgets.py
#	netbox/extras/graphql/types.py
#	netbox/extras/models/configs.py
#	netbox/extras/tests/test_templatetags.py
#	netbox/ipam/choices.py
#	netbox/ipam/forms/model_forms.py
#	netbox/netbox/configuration_example.py
#	netbox/netbox/filtersets.py
#	netbox/netbox/tests/test_api.py
#	netbox/netbox/tests/test_scaffold.py
#	netbox/netbox/tests/test_tables.py
#	netbox/project-static/dist/netbox.js
#	netbox/project-static/dist/netbox.js.map
#	netbox/project-static/package.json
#	netbox/project-static/yarn.lock
#	netbox/release.yaml
#	netbox/translations/cs/LC_MESSAGES/django.mo
#	netbox/translations/cs/LC_MESSAGES/django.po
#	netbox/translations/da/LC_MESSAGES/django.mo
#	netbox/translations/da/LC_MESSAGES/django.po
#	netbox/translations/de/LC_MESSAGES/django.mo
#	netbox/translations/de/LC_MESSAGES/django.po
#	netbox/translations/en/LC_MESSAGES/django.po
#	netbox/translations/es/LC_MESSAGES/django.mo
#	netbox/translations/es/LC_MESSAGES/django.po
#	netbox/translations/fr/LC_MESSAGES/django.mo
#	netbox/translations/fr/LC_MESSAGES/django.po
#	netbox/translations/it/LC_MESSAGES/django.mo
#	netbox/translations/it/LC_MESSAGES/django.po
#	netbox/translations/ja/LC_MESSAGES/django.mo
#	netbox/translations/ja/LC_MESSAGES/django.po
#	netbox/translations/ko/LC_MESSAGES/django.mo
#	netbox/translations/ko/LC_MESSAGES/django.po
#	netbox/translations/lv/LC_MESSAGES/django.mo
#	netbox/translations/lv/LC_MESSAGES/django.po
#	netbox/translations/nl/LC_MESSAGES/django.mo
#	netbox/translations/nl/LC_MESSAGES/django.po
#	netbox/translations/pl/LC_MESSAGES/django.mo
#	netbox/translations/pl/LC_MESSAGES/django.po
#	netbox/translations/pt/LC_MESSAGES/django.mo
#	netbox/translations/pt/LC_MESSAGES/django.po
#	netbox/translations/ru/LC_MESSAGES/django.mo
#	netbox/translations/ru/LC_MESSAGES/django.po
#	netbox/translations/tr/LC_MESSAGES/django.mo
#	netbox/translations/tr/LC_MESSAGES/django.po
#	netbox/translations/uk/LC_MESSAGES/django.mo
#	netbox/translations/uk/LC_MESSAGES/django.po
#	netbox/translations/zh/LC_MESSAGES/django.mo
#	netbox/translations/zh/LC_MESSAGES/django.po
#	netbox/utilities/jinja2.py
#	netbox/utilities/tests/test_filters.py
#	requirements.txt
2026-07-28 14:24:24 -04:00
bctiemann abe4a2cd9e
Closes #22685: Add "any" lookup for tag & tag_id filters 2026-07-22 08:20:09 -04:00
bctiemann d88b6a65dd
Closes #18159: Expose snapshots to Event Rule condition evaluation (#22637)
Expose an event's prechange and postchange snapshots to event rule
condition evaluation, making snapshots.prechange.<attr> and
snapshots.postchange.<attr> available through the existing dot-path
syntax.

Add changed and unchanged snapshot operators for comparing an attribute
across the two snapshots without requiring a condition value. These
operators support rules such as firing only when a field transitions to a
specific state.

Make condition values optional only for snapshot operators by introducing
a missing-value sentinel, while preserving value requirements for all
other operators. Reject invalid combinations such as using changed or
unchanged with an explicit value or with an attr starting with snapshots.

Fail closed when condition paths traverse invalid snapshot structures,
including raw scalar snapshot values such as status strings, by treating
unresolvable snapshot-operator paths as missing and converting invalid
direct paths to InvalidCondition.

Document the new snapshot path syntax, changed and unchanged operators,
create/delete snapshot behavior, and the serialization differences
between snapshot data and REST API data. Add regression and integration
tests covering validation, transition behavior, null snapshot edge cases,
direct snapshot paths, and event rule evaluation.
2026-07-11 18:32:22 +02:00
mburggraf f9ce0a6741
Closes #22464: Update Documentation to use v2 Tokens in examples (#22477) 2026-06-17 13:44:29 -07:00
mr1716 122e2d13dd #20175 Fix Grammatical Error Related To Capitalization 2025-08-25 14:28:35 -04:00
Artem Kotik c40bfb1445 Add regex and iregex filter lookup expressions and corresponding tests 2025-07-18 16:56:54 +02:00
Jeremy Stretch da6a1ef03e Clean up the Markdown reference guide 2024-03-26 16:26:47 -04:00
Jeremy Stretch 1afac47178 Documentation cleanup 2023-12-05 08:05:44 -05:00
Kenny Y 22e474ff96 Update attr in conditions example 2023-11-02 10:22:54 -04:00
Jeremy Stretch 480f83c42d Closes #13585: Introduce 'empty' lookup for numeric value filters 2023-08-28 15:25:37 -04:00
kkthxbye df499ea8ac
Fixes #11459 - Allow using null in conditions (#11722)
* Fixes #11459 - Allow using null in conditions
- Update docs to reflect this
- Change docs example from primary_ip to primary_ip4 as computed properties are not serialized when queuing webhooks

* Update netbox/extras/conditions.py

---------

Co-authored-by: Simon Toft <SITO@telenor.dk>
Co-authored-by: Jeremy Stretch <jstretch@netboxlabs.com>
2023-02-13 17:44:35 -05:00
Robin Schneider 07df622b59 NetBox should always be referred to as NetBox [DATALAD RUNCMD]
=== Do not change lines below ===
{
 "chain": [],
 "cmd": "git ls-files -z . | xargs --null -I '()' find './()' -type f -not -name 'style-guide.md' -print0 | xargs --null sed --in-place --regexp-extended 's/\\bNetbox\\b/NetBox/g;'",
 "exit": 0,
 "extra_inputs": [],
 "inputs": [],
 "outputs": [],
 "pwd": "."
}
^^^ Do not change lines above ^^^
2023-01-05 16:06:00 -05:00
jeremystretch 5da3cab4de Reorganize documentation 2022-08-04 14:11:52 -04:00
kkthxbye-code cf76d5c46a Move markdown documentation to docs 2022-06-16 22:26:37 +02:00
jeremystretch 4b81d86311 Closes #8376: Correct example condition defitinions; call out value vs label ealuation for choice fields 2022-01-18 11:31:39 -05:00
jeremystretch dcececf9c0 Improve documentation and testing for conditions 2021-11-03 14:02:43 -04:00
jeremystretch 2423e0872f Documentation & changelog for #6238 2021-10-25 09:52:08 -04:00