Open
Description
Report hasn't been filed before.
- I have verified that the bug I'm about to report hasn't been filed before.
What version of drizzle-orm
are you using?
0.40.0
What version of drizzle-kit
are you using?
0.30.4
Other packages
No response
Describe the Bug
I noticed when using getTableColumns to perform a selectionin an API request, and then assigning extra values to that selection for joins etc, the next call to getTableColumns on a subsequent API request also contained the additional values. Here is an easy way to reproduce:
const selection = getTableColumns(table)
console.log(Object.keys(selection))
/* logs:
[
'id',
...<other cols>
]
*/
Object.assign(selection, {"foo": "bar"})
const anotherSelection = getTableColumns(table)
console.log(Object.keys(anotherSelection))
/* logs:
[
'id',
...<other cols>,
'foo'
]
*/
I have fixed this by simply assigning getTableColumns(table)
to a fresh empty object for each request, and performing the extra fields mutation on this new object. But does this mean that a table's columns can be arbitrarily mutated so that the function will return the additional values in all scopes? That seems like it could easily trip people up, shouldn't the function return an immutable?
Thanks!