|
|
|
|
|
by happyslobro
3621 days ago
|
|
Why does PG create fields with null values? Intfield was undefined when it was inserted for the `"foo": "bar"` row. Does this mean that if you insert 10K JSON rows, and each one has a unique field / key, then a SELECT * will return a 10K rows * 10K fields, most of which are null? Having the DB automatically insert null fields also makes it harder to use Javascript's `Object.assign` to populate undefined fields with default values: Object.assign({a: "default-a", b: "default-b"}, {a: "db-a"}) {a: "db-a", b: "default-b"} VS Object.assign({a: "default-a", b: "default-b"}, {a: "db-a", b: null}) {a: "db-a", b: null} null and undefined are two different concepts in JS. It is like the difference between "there is nothing here" and "I don't know if there is anything here". |
|