Skip to content

Commit a23cff7

Browse files
committed
Fix (future) registering scalars that extend other scalars
The codec registry does not respect the `customScalarCodecs` if it's a scalar derived from a base scalar. It will instead use the base scalar's derive method to basically copy the base scalar functionality for that scalar extending it. Switching instead to the `codecs` map/LRU fixes this. It acts like a build cache and respects all entries. Idk why there are so many different maps representing similar things: codecs, codecsBuildCache, customScalarCodecs, SCALAR_CODECS. All these hold codec instances by ID.
1 parent 250fd52 commit a23cff7

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/core/edgedb/codecs/register-codecs.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { delay, mapEntries } from '@seedcompany/common';
22
import { $, Client } from 'edgedb';
33
import { KNOWN_TYPENAMES } from 'edgedb/dist/codecs/consts.js';
4-
import { ScalarCodec } from 'edgedb/dist/codecs/ifaces.js';
4+
import LRU from 'edgedb/dist/primitives/lru.js';
55
import { retry } from '~/common/retry';
66
import { ScalarCodecClass } from './type.util';
77

@@ -52,7 +52,7 @@ const register = (
5252
scalarIdsByName?: ReadonlyMap<string, string>,
5353
) => {
5454
const registry = (client as any).pool._codecsRegistry;
55-
const codecs: Map<string, ScalarCodec> = registry.customScalarCodecs;
55+
const codecs: LRU<string, InstanceType<ScalarCodecClass>> = registry.codecs;
5656

5757
for (const scalarCodec of scalarCodecs) {
5858
const typeName = `${scalarCodec.info.module}::${scalarCodec.info.type}`;

0 commit comments

Comments
 (0)