-
Notifications
You must be signed in to change notification settings - Fork 61
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
Simplify namedtuple/object JS objects #310
Conversation
Looking at some test failures I have second thoughts about this...
While using Symbols to add methods/extra info to objects works (Symbols are excluded from JSON.serialize), not using proper types (with proper prototypes) makes dumps like this unnecessarily messy. Maybe we're better off keeping our code as is and just fix nextjs to serialize things correctly? The other way to fix this would be:
@jaclarke thoughts re (3)? |
The root of the issue is that these implicit properties and internal methods are now enumerable and throwing off our I also dropped the
|
The inspector already works by walking the codecs tree, and I think the only place where it currently needs to use |
OK, I'm killing the object introspection API then. With it gone we no longer need custom inspect.
Colin, I've just pushed an even more radical approach:
With no implicit fields we don't need to use |
Forced-pushed a lint fix |
While there drop the custom inspect, the introspection API (we can introspect codecs), and kill implicit object IDs.
This PR simplifies how EdgeDB's object and namedtuple types are decoded into JS.
Currently we generate custom JS types dynamically for every EdgeDB object and namedtuple. The advantage of that, particularly for namedtuples, is that we can support both
tuple[index]
andtuple.name
notations. The main disadvantage is that some frameworks (cough, nextjs, cough) hardcode JSON serialization and only recognize vanilla JS types, meaning that our custom object/namedtuple types are not supported.Fix this by changing the code to use vanilla JS objects for both EdgeDB object & namedtuple types.
Backwards-incompatible changes:
namedtuple objects can no longer be index by numbers. I.e.
nt[0]
expressions are no longer supported. The good news is that we never support proper typing for such expressions.namedtuple objects no longer have the
.length
attribute (this is a net improvement though).Implicit fields for objects are now encoded via symbols. Before, getting a type name was possible with simple
obj.__tname__
; with this PR it will beobj[Symbol.for('__tname__')]
.While there, drop the
getSubcodecsNames()
method that seems to be unused by edgedb.com and edgedb-studio repos. @jaclarke please confirm.When landed, we should bump the version to
0.20.0
.