Leo CamusandDarkSky 0315c8cda0 fix(core): ignore cleared number values in collection rules (#15610)
## Description

I noticed that clearing a number property in the doc info panel doesn't
really make it empty as far as collection rules are concerned.
`NumberValue` saves the trimmed input on blur, so a cleared field is
stored as `''`, and the three number providers in `collection-rules` all
pass the raw value through `Number()`, which turns `''` into `0`. The
result is that a doc whose number was cleared:

- matches the `= 0`, `< n`, `≤ n` filters (and `≥ 0`), even though
`is-empty` correctly reports it as empty;
- is sorted as if it held `0` by the number order-by instead of being
skipped like a doc that never had a value;
- ends up in the `0` group of the number group-by.

A doc that never had the property (value `undefined`) already behaves
correctly, since `Number(undefined)` is `NaN` and all three providers
drop `NaN`. The fix makes an empty string follow that same path (`value
? Number(value) : NaN`) in `filters/number.ts`, `order-by/number.ts` and
`group-by/number.ts`. A stored `'0'` is a non-empty string, so a real
zero is unaffected.

I added `collection-rules/__tests__/number.spec.ts`, which feeds the
providers four docs (`'0'`, `'3'`, `''`, `undefined`). On `canary` three
of its four tests fail:

```
AssertionError: expected [ 'cleared', 'zero' ] to deeply equal [ 'zero' ]
AssertionError: expected [ 'zero', 'cleared', 'three' ] to deeply equal [ 'zero', 'three' ]
AssertionError: expected { '0': [ 'zero', 'cleared' ], …(1) } to deeply equal { '0': [ 'zero' ], '3': [ 'three' ] }
Tests  3 failed | 1 passed (4)
```

With the change all four pass, and `yarn vitest run
packages/frontend/core/src/modules/collection-rules
packages/frontend/core/src/modules/journal` is green (25 tests).
`oxlint` and `oxfmt --check` are clean on the touched files.

## Checklist

- [x] I have signed the [AFFiNE Contributor License
Agreement](https://cla-assistant.io/toeverything/AFFiNE) — required
before merge; the `license/cla` check must be green ([how it
works](https://github.com/toeverything/AFFiNE/blob/canary/docs/BUILDING.md#sign-the-cla-first))
- [x] The PR targets the `canary` branch and its title follows
[Conventional Commits](https://www.conventionalcommits.org/)
- [x] Tests are added or updated where it makes sense
- [ ] `yarn lint` and `yarn typecheck` pass locally
- [x] If the PR code includes AI-generated edits, I have carefully
reviewed it to ensure that the scope of the PR is consistent with what
is claimed in the title and description, and that there are no redundant
or invalid implementations.
- [x] I agree that maintainers may close the PR without discussion if
they consider the code quality to be too low.

Found by a defect-hunting pipeline I build and run
([Dev-next-gen](https://github.com/Dev-next-gen)), using Claude Code
with Anthropic's Claude Opus 5.

"Nothing this pipeline produces is submitted without human approval. The
entire pull request — the code change, the tests and this description —
was reviewed by a human before the pipeline was allowed to submit it."

(@Dev-next-gen)


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->

## Summary by CodeRabbit

- **New Features**
- Search results can include database rows linked to matching documents,
with offset and cursor pagination.
- Linked-document references in database titles display resolved page
titles and remain searchable as titles change.
- AFFiNE AI adds Claude Haiku and updates available Claude and Gemini
models.
- Generated images can appear directly in AI responses when a shareable
link is unavailable.
- Select all in the LaTeX editor works with the platform’s standard
keyboard shortcut.

- **Bug Fixes**
- Cleared or unset numeric properties are no longer treated as `0` in
comparisons, sorting, or grouping.
- Linked document IDs resolve consistently across document actions and
views.

- **Tests**
- Added coverage for numeric filters, sorting, grouping, and emptiness
checks.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: DarkSky <darksky2048@gmail.com>
2026-11-23 22:59:22 +08:00
2026-10-10 23:28:25 +08:00
2026-10-26 16:49:45 +08:00
2026-02-06 19:49:02 +08:00
2023-07-10 06:19:59 +00:00
2026-10-22 16:38:31 +08:00
2026-11-23 17:19:29 +08:00
2026-11-23 17:19:29 +08:00
2026-08-11 03:09:54 +08:00
2023-05-03 00:47:43 -05:00
2025-12-29 19:08:49 +08:00
2023-09-15 07:50:00 +00:00
2026-07-15 13:25:57 +08:00

AFFiNE.Pro
Write, Draw and Plan All at Once

affine logo

A privacy-focused, local-first, open-source, and ready-to-use alternative for Notion & Miro.
One hyper-fused platform for wildly creative minds.



AFFiNE - One app for all - Where Notion meets Miro | Product Hunt


Releases All Contributors TypeScript-version-icon


Docs, canvas and tables are hyper-merged with AFFiNE - just like the word affine (əˈfʌɪn | a-fine).

Getting started & staying tuned with us.

Star us, and you will receive all release notifications from GitHub without any delay!

What is AFFiNE

AFFiNE is an open-source, all-in-one workspace and an operating system for all the building blocks that assemble your knowledge base and much more -- wiki, knowledge management, presentation and digital assets. It's a better alternative to Notion and Miro.

Features

A true canvas for blocks in any form. Docs and whiteboard are now fully merged.

  • Many editor apps claim to be a canvas for productivity, but AFFiNE is one of the very few which allows you to put any building block on an edgeless canvas -- rich text, sticky notes, any embedded web pages, multi-view databases, linked pages, shapes and even slides. We have it all.

Multimodal AI partner ready to kick in any work

  • Write up professional work report? Turn an outline into expressive and presentable slides? Summary an article into a well-structured mindmap? Sorting your job plan and backlog for tasks? Or... draw and code prototype apps and web pages directly all with one prompt? With you, AFFiNE AI pushes your creativity to the edge of your imagination, just like Canvas AI to generate mind map for brainstorming.

Local-first & Real-time collaborative

  • We love the idea of local-first that you always own your data on your disk, in spite of the cloud. Furthermore, AFFiNE supports real-time sync and collaborations on web and cross-platform clients.

Self-host & Shape your own AFFiNE

  • You have the freedom to manage, self-host, fork and build your own AFFiNE. Plugin community and third-party blocks are coming soon. More tractions on Blocksuite. Check there to learn how to self-host AFFiNE.

Acknowledgement

“We shape our tools and thereafter our tools shape us”. A lot of pioneers have inspired us along the way, e.g.:

  • Quip & Notion with their great concept of “everything is a block”
  • Trello with their Kanban
  • Airtable & Miro with their no-code programmable datasheets
  • Miro & Whimiscal with their edgeless visual whiteboard
  • Remote & Capacities with their object-based tag system

There is a large overlap of their atomic “building blocks” between these apps. They are not open source, nor do they have a plugin system like Vscode for contributors to customize. We want to have something that contains all the features we love and also goes one step even further.

Thanks for checking us out, we appreciate your interest and sincerely hope that AFFiNE resonates with you! 🎵 Checking https://affine.pro/ for more details ions.

Contributing

Bug Reports Feature Requests Questions/Discussions AFFiNE Community
Create a bug report Submit a feature request Check GitHub Discussion Visit the AFFiNE's Discord
Something isn't working as expected An idea for a new feature, or improvements Discuss and ask questions A place to ask, learn and engage with others

Calling all developers, testers, tech writers and more! Contributions of all types are more than welcome, you can read more in docs/types-of-contributions.md. If you are interested in contributing code, read our docs/CONTRIBUTING.md and feel free to check out our GitHub issues to get stuck in to show us what you’re made of.

Before you start contributing, please sign our Contributor License Agreement — it takes less than a minute with your GitHub account. Pull requests cannot be merged until every committer has signed (the license/cla check on your PR). Full text: CLA.md.

For bug reports, feature requests and other suggestions you can also create a new issue and choose the most appropriate template for your feedback.

For translation and language support you can visit our Discord.

If you have questions, you are welcome to contact us. One of the best places to get more info and learn more is in the Discord where you can engage with other like-minded individuals.

Templates

AFFiNE now provides pre-built templates from our team. Following are the Top 10 most popular templates among AFFiNE users,if you want to contribute, you can contribute your own template so other people can use it too.

Blog

Welcome to the AFFiNE blog section! Here, you’ll find the latest insights, tips, and guides on how to maximize your experience with AFFiNE and AFFiNE AI, the leading Canvas AI tool for flexible note-taking and creative organization.

Ecosystem

Name
@affine/component AFFiNE Component Resources
@toeverything/theme AFFiNE theme

Upstreams

We would also like to give thanks to open-source projects that make AFFiNE possible:

  • Blocksuite - 💠 BlockSuite is the open-source collaborative editor project behind AFFiNE.

  • y-octo - 🐙 y-octo is a native, high-performance, thread-safe YJS CRDT implementation, serving as the core engine enabling the AFFiNE Client/Server to achieve "local-first" functionality.

  • OctoBase - 🐙 OctoBase is the open-source database behind AFFiNE, local-first, yet collaborative. A light-weight, scalable, data engine written in Rust.

  • yjs - Fundamental support of CRDTs for our implementation on state management and data sync on web.

  • electron - Build cross-platform desktop apps with JavaScript, HTML, and CSS.

  • React - The library for web and native user interfaces.

  • napi-rs - A framework for building compiled Node.js add-ons in Rust via Node-API.

  • Jotai - Primitive and flexible state management for React.

  • async-call-rpc - A lightweight JSON RPC client & server.

  • Vite - Next generation frontend tooling.

  • Other upstream dependencies.

Thanks a lot to the community for providing such powerful and simple libraries, so that we can focus more on the implementation of the product logic, and we hope that in the future our projects will also provide a more easy-to-use knowledge base for everyone.

Contributors

We would like to express our gratitude to all the individuals who have already contributed to AFFiNE! If you have any AFFiNE-related project, documentation, tool or template, please feel free to contribute it by submitting a pull request to our curated list on GitHub: awesome-affine.

contributors

Self-Host

Begin with Docker to deploy your own feature-rich, unrestricted version of AFFiNE. Our team is diligently updating to the latest version. For more information on how to self-host AFFiNE, please refer to our documentation.

Deploy to Render

Run on Sealos

Feature Request

For feature requests, please see discussions.

Building

Codespaces

From the GitHub repo main page, click the green "Code" button and select "Create codespace on master". This will open a new Codespace with the (supposedly auto-forked AFFiNE repo cloned, built, and ready to go).

Local

See BUILDING.md for instructions on how to build AFFiNE from source code.

Contributing

We welcome contributions from everyone. See docs/contributing/tutorial.md for details.

License

Editions

  • AFFiNE Community Edition (CE) is the current available version, it's free for self-host under the MIT license.

  • AFFiNE Enterprise Edition (EE) is yet to be published, it will have more advanced features and enterprise-oriented offerings, including but not exclusive to rebranding and SSO, advanced admin and audit, etc., you may refer to https://affine.pro/pricing for more information

See LICENSE for details.

Languages
TypeScript 81.1%
Rust 11.9%
Swift 4.7%
Kotlin 1.1%
JavaScript 0.4%
Other 0.6%