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
Hi there. Thanks for this library, it's very much exactly what I was looking for :)
I'm prototyping something with SQLite -- so maybe it's a little my fault for even using it -- but I feel like this is a weird gotcha with a plausibly meaningful improvement to-hand.
I added the ParseJSONResultsPlugin for use in some queries I've written, and later encountered the unexpected behavior that it yolo-parses all columns if they "look like" JSON, whether I wanted it to or not. Because of the way Kysely works, I had typed that table with a string column, but was getting an object and crashing out, without TypeScript warning me about this behavior.
I feel like this is weird behavior that goes against the intent of the library, and would be improved by opting in to JSON parsing on a column so that the expectations (and the types) are correct and explicit. Obviously, Kysely can't know that the string column contains JSON, but that's why it's particularly weird that it can turn any text column into an object without the query itself saying to do so. This all-or-nothing behavior makes the plugin kinda useless, because it creates a scenario where you can't rely on the query builder to give you the types you've told it to give you.
I recognize that I can write my own transforms to behave how I want them to, but since this plugin is included in the library itself, it seems that it should be a bit tighter than it currently is. In particular, I was thrown by the examples, e.g. on this page which seem to indicate this sort of opt-in behavior.
Thoughts?
The text was updated successfully, but these errors were encountered:
Hi there. Thanks for this library, it's very much exactly what I was looking for :)
I'm prototyping something with SQLite -- so maybe it's a little my fault for even using it -- but I feel like this is a weird gotcha with a plausibly meaningful improvement to-hand.
I added the ParseJSONResultsPlugin for use in some queries I've written, and later encountered the unexpected behavior that it yolo-parses all columns if they "look like" JSON, whether I wanted it to or not. Because of the way Kysely works, I had typed that table with a
string
column, but was getting an object and crashing out, without TypeScript warning me about this behavior.I feel like this is weird behavior that goes against the intent of the library, and would be improved by opting in to JSON parsing on a column so that the expectations (and the types) are correct and explicit. Obviously, Kysely can't know that the string column contains JSON, but that's why it's particularly weird that it can turn any text column into an object without the query itself saying to do so. This all-or-nothing behavior makes the plugin kinda useless, because it creates a scenario where you can't rely on the query builder to give you the types you've told it to give you.
I recognize that I can write my own transforms to behave how I want them to, but since this plugin is included in the library itself, it seems that it should be a bit tighter than it currently is. In particular, I was thrown by the examples, e.g. on this page which seem to indicate this sort of opt-in behavior.
Thoughts?
The text was updated successfully, but these errors were encountered: