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

NULL values should be mapped to undefined #76

Closed
malthe opened this issue Nov 22, 2023 · 2 comments
Closed

NULL values should be mapped to undefined #76

malthe opened this issue Nov 22, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@malthe
Copy link
Owner

malthe commented Nov 22, 2023

TypeScript prefers undefined to null because it means missing value and as a property, there is syntax to support this – the ?-operator.

We should convert the SQL NULL value into undefined instead of null for this reason.

Note that JSON data, we'll always have null for a null value (there is no undefined in JSON, those properties are simply dropped).

@nitwhiz
Copy link
Collaborator

nitwhiz commented Nov 26, 2023

In the same guide:

These are Coding Guidelines for Contributors to TypeScript. This is NOT a prescriptive guideline for the TypeScript community. These guidelines are meant for contributors to the TypeScript project's codebase. We have chosen many of them for team consistency.

The optional chaining operator supports both, undefined and null.

SQL NULL should be null. A value not being there (because the select is missing it or something else) is undefined. null is a real value we can type with this, like string or number. If you use null for both cases, it's hard to track the issue of a missing column down.

@malthe malthe mentioned this issue Nov 27, 2023
@malthe
Copy link
Owner Author

malthe commented Nov 27, 2023

@nitwhiz I have reverted the commits directly to the master branch, moving them into a pull request (linked here) for further discussion.

@malthe malthe closed this as not planned Won't fix, can't repro, duplicate, stale Feb 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants