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
An expression is called referentially transparent if it can be replaced with its corresponding value (and vice-versa) without changing the program's behavior.
It would simplify Kysely usage and unlock further optimizations. And it's little change I believe.
Take a look how I'm using Kysely in React:
useThingsDB is React Hook (composed from other hooks but that's irrelevant now), which takes Kysely query as a parameter. Note useCallback usage. It makes callback stable because it must be stable.
What am I proposing is toString overload that would serialize Kysely toString and fromString that would deserialize it. With such API, it would be easy to cache etc. Kysely queries.
That should be doable, but the type of db.deserialize(serialized) would obviously be wrong, since we can't deserialize the type from just a string. The deserialized query would be something like QueryBuilder<DB, any, unknown>.
I don't think we should override toString(). People would assume toString() returns the SQL and fromString parses SQL into a QueryBuilder.
It would simplify Kysely usage and unlock further optimizations. And it's little change I believe.
Take a look how I'm using Kysely in React:
useThingsDB
is React Hook (composed from other hooks but that's irrelevant now), which takes Kysely query as a parameter. NoteuseCallback
usage. It makes callback stable because it must be stable.What am I proposing is toString overload that would serialize Kysely toString and fromString that would deserialize it. With such API, it would be easy to cache etc. Kysely queries.
What do you think?
The text was updated successfully, but these errors were encountered: