You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We currently do not define any top-level schema fields as nullable because Protobuf doesn't have a proper representation of null. However, there's a misalignment between this and how SQLite works, where there's no undefined / void column type in SQLite and so optional fields are stored and read as null. In Mapeo Core, after reading values from SQLite (via Drizzle), we update fields with null values to undefined to match the Mapeo Schema definition of an optional field (link).
However, there's currently no protection against us defining a nullable top-level field in the schema, which will cause an issue at the SQLite-to-MapeoCore level because we will replace an intentionalnull value with undefined as opposed to leaving it untouched. This does not affect schema fields with a nested JSON-like value definition since we store the JSON as-is in SQLite.
Recommendations:
add a test to prevent maintainers from defining a top-level nullable field on a schema
update the schema generation implementation to warn/error if it detects a change that introduces this
The text was updated successfully, but these errors were encountered:
achou11
changed the title
Prevent schemas from using nullable type for top-leve field definitions
Prevent schemas from using nullable type for top-level field definitions
Aug 7, 2023
We currently do not define any top-level schema fields as nullable because Protobuf doesn't have a proper representation of
null
. However, there's a misalignment between this and how SQLite works, where there's noundefined
/ void column type in SQLite and so optional fields are stored and read asnull
. In Mapeo Core, after reading values from SQLite (via Drizzle), we update fields withnull
values toundefined
to match the Mapeo Schema definition of an optional field (link).However, there's currently no protection against us defining a nullable top-level field in the schema, which will cause an issue at the SQLite-to-MapeoCore level because we will replace an intentional
null
value withundefined
as opposed to leaving it untouched. This does not affect schema fields with a nested JSON-like value definition since we store the JSON as-is in SQLite.Recommendations:
The text was updated successfully, but these errors were encountered: