Translate pg sql NULL to javascript undefined
See original GitHub issueI don’t know, maybe current translation NULL to null have some reasons, but from my point of view undefined is more useful, because undefined omitted in JSON automatically:
JSON.stringify({ x: null }) // {"x":null}
JSON.stringify({ x: undefined }) // {}
@brianc What do you think about it?
Issue Analytics
- State:
- Created 6 years ago
- Reactions:20
- Comments:18 (12 by maintainers)
Top Results From Across the Web
How to insert undefined value as null for pg node js
you can define a undefined variable using || operator. Ex var a ; var b = a || null;.
Read more >How NULL and empty strings are treated in PostgreSQL vs ...
Oracle reads empty strings as NULLs, while PostgreSQL treats them as empty. Concatenating NULL values with non-NULL characters results in ...
Read more >Cannot convert undefined or null to Object in JavaScript
The "Cannot convert undefined or null to Object" error occurs when we pass a null or an undefined value to a function that...
Read more >node-mssql | Microsoft SQL Server client for Node.js
undefined and NaN values are automatically converted to null values. Example. request.input('input_parameter', ...
Read more >Documentation: 8.2: PostgreSQL Error Codes
Error Code Meaning Constant
00000 SUCCESSFUL COMPLETION successful_completion
01000 WARNING warning
0100C DYNAMIC RESULT SETS RETURNED dynamic_result_sets_returned
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

I use
nullas an intentional “nothing” value, sinceundefinedtends to be a mistake (given it’s what you get by reading a property that doesn’t exist).Strongly −1 on implementing this, as a setting or otherwise.
I don’t think it’s a bad idea at all, but it has potential to be a very subtle very breaking change if people are relying on strict equality checks for
nullon some of their query results. I think at this point we should consider the ship sailed on usingnullinstead ofundefinedfor result values & then if you want to strip them off in your own app you could do something likerows.map(row => _.omit(row, (val, key) => val === nullor something? That’s a kinda unfortunate side-effect of having two empty values in JavaScript.I tagged to version 7.x so I can think about it when I start working on some backwards incompat changes to the next breaking version…but I’m leaning towards “that is how it is” right now.