Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LibSQL: Rewrite the SQL::Value type to be contained within one class #15312

Merged
merged 5 commits into from Oct 14, 2022

Conversation

trflynn89
Copy link
Member

Reviving some old branches to make LibSQL more feasible to be used to e.g. store cookies from the Browser.

Currently, the Value class is essentially a "pImpl" wrapper around the
ValueImpl hierarchy of classes. This is a bit difficult to follow and
reason about, as methods jump between the Value class and its impl
classes.

This changes the Variant held by Value to instead store the specified
types (String, int, etc.) directly. In doing so, the ValueImpl classes
are removed, and all methods are now just concise Variant visitors.

As part of this rewrite, support for the "array" type is dropped (or
rather, just not re-implemented) as it was unused. If it's needed in the
future, support can be re-added.

This does retain the ability for non-NULL types to store NULL values
(i.e. an empty Optional). I tried dropping this support as well, but it
is depended upon by the on-disk storage classes in non-trivial ways.

Copy link
Member

@alimpfard alimpfard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a nitpick or two

Userland/Libraries/LibSQL/AST/Expression.cpp Outdated Show resolved Hide resolved
Userland/Libraries/LibSQL/Value.cpp Show resolved Hide resolved
These are explicitly needed, and will cause compile errors as headers
moved around in subsequent commits.
No need to allocate here. Also mark these methods as constexpr rather
than inline static.
Force the callers to either know that the type is convertible, or to
handle the conversion failure.
Currently, the Value class is essentially a "pImpl" wrapper around the
ValueImpl hierarchy of classes. This is a bit difficult to follow and
reason about, as methods jump between the Value class and its impl
classes.

This changes the Variant held by Value to instead store the specified
types (String, int, etc.) directly. In doing so, the ValueImpl classes
are removed, and all methods are now just concise Variant visitors.

As part of this rewrite, support for the "array" type is dropped (or
rather, just not re-implemented) as it was unused. If it's needed in the
future, support can be re-added.

This does retain the ability for non-NULL types to store NULL values
(i.e. an empty Optional). I tried dropping this support as well, but it
is depended upon by the on-disk storage classes in non-trivial ways.
@kleinesfilmroellchen kleinesfilmroellchen added the 👀 pr-needs-review PR needs review from a maintainer or community member label Oct 14, 2022
@alimpfard alimpfard removed the 👀 pr-needs-review PR needs review from a maintainer or community member label Oct 14, 2022
@alimpfard alimpfard merged commit 1524288 into SerenityOS:master Oct 14, 2022
@trflynn89 trflynn89 deleted the sql_value branch October 14, 2022 14:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants