Skip to content

Commit

Permalink
Build from edgedb-js 71b1d7ede585e2da261e1b24a9ba1f49f325eaae
Browse files Browse the repository at this point in the history
  • Loading branch information
edgedb-ci committed Jul 27, 2022
1 parent 669c5d8 commit ff45285
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 7 deletions.
23 changes: 22 additions & 1 deletion _src/reflection/generators/generateFunctionTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,10 @@ export function generateReturnCardinality(
if (
returnTypemod === "SetOfType" &&
name !== "std::if_else" &&
name !== "std::assert_exists"
name !== "std::assert_exists" &&
name !== "std::union" &&
name !== "std::coalesce" &&
name !== "std::distinct"
) {
return `$.Cardinality.Many`;
}
Expand All @@ -518,6 +521,24 @@ export function generateReturnCardinality(
: []),
];

if (name === "std::union") {
return `$.cardinalityUtil.mergeCardinalities<
$.cardinalityUtil.paramCardinality<${cardinalities[0].genTypeName}>,
$.cardinalityUtil.paramCardinality<${cardinalities[1].genTypeName}>
>`;
}

if (name === "std::coalesce") {
return `$.cardinalityUtil.orCardinalities<
$.cardinalityUtil.paramCardinality<${cardinalities[0].genTypeName}>,
$.cardinalityUtil.paramCardinality<${cardinalities[1].genTypeName}>
>`;
}

if (name === "std::distinct") {
return `$.cardinalityUtil.paramCardinality<${cardinalities[0].genTypeName}>`;
}

if (name === "std::if_else") {
return (
`$.cardinalityUtil.multiplyCardinalities<` +
Expand Down
5 changes: 5 additions & 0 deletions _src/reflection/queries/getTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ const numberType: ScalarType = {
material_id: null,
bases: [],
};

export const typeMapping = new Map([
[
"00000000-0000-0000-0000-000000000103", // int16
Expand Down Expand Up @@ -246,6 +247,10 @@ export async function getTypes(
// id: typeMapping.get(base.id)?.id ?? base.id,
// }));
break;
case "range":
type.range_element_id =
typeMapping.get(type.range_element_id)?.id ?? type.range_element_id;
break;
case "array":
// type.array_element_id =
// typeMapping.get(type.array_element_id)?.id ??
Expand Down
35 changes: 29 additions & 6 deletions _src/reflection/util/genutil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export const scalarToLiteralMapping: {
} = {
"std::int16": {type: "number"},
"std::int32": {type: "number"},
"std::int64": {type: "number"},
"std::int64": {type: "number", extraTypes: ["string"]},
"std::float32": {type: "number"},
"std::float64": {type: "number"},
"std::number": {
Expand All @@ -55,23 +55,46 @@ export const scalarToLiteralMapping: {
"std::bool": {type: "boolean", literalKind: "typeof"},
"std::bigint": {type: "bigint", literalKind: "typeof"},
"std::bytes": {type: "Buffer", literalKind: "instanceof"},
"std::datetime": {type: "Date", literalKind: "instanceof"},
"std::duration": {type: "edgedb.Duration", literalKind: "instanceof"},
"std::datetime": {
type: "Date",
literalKind: "instanceof",
extraTypes: ["string"],
},
"std::duration": {
type: "edgedb.Duration",
literalKind: "instanceof",
extraTypes: ["string"],
},
"cal::local_datetime": {
type: "edgedb.LocalDateTime",
literalKind: "instanceof",
extraTypes: ["string"],
},
"cal::local_date": {
type: "edgedb.LocalDate",
literalKind: "instanceof",
extraTypes: ["string"],
},
"cal::local_time": {
type: "edgedb.LocalTime",
literalKind: "instanceof",
extraTypes: ["string"],
},
"cal::local_date": {type: "edgedb.LocalDate", literalKind: "instanceof"},
"cal::local_time": {type: "edgedb.LocalTime", literalKind: "instanceof"},
"cal::relative_duration": {
type: "edgedb.RelativeDuration",
literalKind: "instanceof",
extraTypes: ["string"],
},
"cal::date_duration": {
type: "edgedb.DateDuration",
literalKind: "instanceof",
extraTypes: ["string"],
},
"cfg::memory": {
type: "edgedb.ConfigMemory",
literalKind: "instanceof",
extraTypes: ["string"],
},
"cfg::memory": {type: "edgedb.ConfigMemory", literalKind: "instanceof"},
};

export const literalToScalarMapping: {
Expand Down

0 comments on commit ff45285

Please sign in to comment.