Skip to content

Commit

Permalink
update stdlib
Browse files Browse the repository at this point in the history
  • Loading branch information
Quin Lynch committed Jun 5, 2024
1 parent e1a797a commit 88b3329
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 41 deletions.
78 changes: 39 additions & 39 deletions src/EdgeDB.Net.QueryBuilder/EdgeQL.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public static IEnumerable<TType> AssertDistinct<TType>(IEnumerable<TType> input,
/// Return the element of *array* at the specified *index*.
/// </summary>
[EdgeQLFunction("array_get", "std", "anytype", false, true)]
public static TType? ArrayGet<TType>(IEnumerable<TType> array, Int64 idx, TType? @default = default)
public static TType? ArrayGet<TType>(IEnumerable<TType> array, Int64 idx, TType? @default)
=> default!;
/// <summary>
/// Return array elements as a set.
Expand All @@ -52,16 +52,16 @@ public static IEnumerable<TType> AssertDistinct<TType>(IEnumerable<TType> input,
public static IEnumerable<TType> ArrayUnpack<TType>(IEnumerable<TType> array)
=> default!;
[EdgeQLFunction("DISTINCT", "std", "anytype", true, false)]
public static IEnumerable<TType> Distinct<TType>(IEnumerable<TType> s = default)
public static IEnumerable<TType> Distinct<TType>(IEnumerable<TType> s)
=> default!;
[EdgeQLFunction("UNION", "std", "anytype", true, false)]
public static IEnumerable<TType> Union<TType>(IEnumerable<TType> s1 = default, IEnumerable<TType> s2 = default)
public static IEnumerable<TType> Union<TType>(IEnumerable<TType> s1, IEnumerable<TType> s2)
=> default!;
[EdgeQLFunction("EXCEPT", "std", "anytype", true, false)]
public static IEnumerable<TType> Except<TType>(IEnumerable<TType> s1 = default, IEnumerable<TType> s2 = default)
public static IEnumerable<TType> Except<TType>(IEnumerable<TType> s1, IEnumerable<TType> s2)
=> default!;
[EdgeQLFunction("INTERSECT", "std", "anytype", true, false)]
public static IEnumerable<TType> Intersect<TType>(IEnumerable<TType> s1 = default, IEnumerable<TType> s2 = default)
public static IEnumerable<TType> Intersect<TType>(IEnumerable<TType> s1, IEnumerable<TType> s2)
=> default!;
/// <summary>
/// Assert that a boolean value is true.
Expand Down Expand Up @@ -158,25 +158,25 @@ public static Boolean Contains(Range<DateOnly> haystack, DateOnly needle)
public static Boolean Contains(MultiRange<DateOnly> haystack, DateOnly needle)
=> default!;
[EdgeQLFunction("IN", "std", "std::bool", false, false)]
public static Boolean In<TType>(TType e = default, IEnumerable<TType> s = default)
public static Boolean In<TType>(TType e, IEnumerable<TType> s)
=> default!;
[EdgeQLFunction("NOT IN", "std", "std::bool", false, false)]
public static Boolean NotIn<TType>(TType e = default, IEnumerable<TType> s = default)
public static Boolean NotIn<TType>(TType e, IEnumerable<TType> s)
=> default!;
[EdgeQLFunction("EXISTS", "std", "std::bool", false, false)]
public static Boolean Exists<TType>(IEnumerable<TType> s = default)
public static Boolean Exists<TType>(IEnumerable<TType> s)
=> default!;
[EdgeQLFunction("LIKE", "std", "std::bool", false, false)]
public static Boolean Like(String str = null, String pattern = null)
public static Boolean Like(String str, String pattern)
=> default!;
[EdgeQLFunction("ILIKE", "std", "std::bool", false, false)]
public static Boolean ILike(String str = null, String pattern = null)
public static Boolean ILike(String str, String pattern)
=> default!;
[EdgeQLFunction("NOT LIKE", "std", "std::bool", false, false)]
public static Boolean NotLike(String str = null, String pattern = null)
public static Boolean NotLike(String str, String pattern)
=> default!;
[EdgeQLFunction("NOT ILIKE", "std", "std::bool", false, false)]
public static Boolean NotILike(String str = null, String pattern = null)
public static Boolean NotILike(String str, String pattern)
=> default!;
/// <summary>
/// A polymorphic function to calculate a "length" of its first argument.
Expand Down Expand Up @@ -293,7 +293,7 @@ public static Int64 SequenceReset(Type seq, Int64 value)
/// Create a `int64` value.
/// </summary>
[EdgeQLFunction("to_int64", "std", "std::int64", false, false)]
public static Int64 ToInt64(String s, String? fmt = null)
public static Int64 ToInt64(String s, String? fmt)
=> default!;
[EdgeQLFunction("sequence_reset", "std", "std::int64", false, false)]
public static Int64 SequenceReset(Type seq)
Expand Down Expand Up @@ -329,7 +329,7 @@ public static BigInteger Round(BigInteger val)
/// Create a `bigint` value.
/// </summary>
[EdgeQLFunction("to_bigint", "std", "std::bigint", false, false)]
public static BigInteger ToBigint(String s, String? fmt = null)
public static BigInteger ToBigint(String s, String? fmt)
=> default!;
/// <summary>
/// Round up to the nearest integer.
Expand Down Expand Up @@ -374,7 +374,7 @@ public static IEnumerable<Decimal> RangeUnpack(Range<Decimal> val, Decimal step)
/// Create a `decimal` value.
/// </summary>
[EdgeQLFunction("to_decimal", "std", "std::decimal", false, false)]
public static Decimal ToDecimal(String s, String? fmt = null)
public static Decimal ToDecimal(String s, String? fmt)
=> default!;
/// <summary>
/// Round up to the nearest integer.
Expand Down Expand Up @@ -455,7 +455,7 @@ public static IEnumerable<Single> RangeUnpack(Range<Single> val, Single step)
/// Create a `float32` value.
/// </summary>
[EdgeQLFunction("to_float32", "std", "std::float32", false, false)]
public static Single ToFloat32(String s, String? fmt = null)
public static Single ToFloat32(String s, String? fmt)
=> default!;
/// <summary>
/// Return the sum of the set of numbers.
Expand Down Expand Up @@ -494,7 +494,7 @@ public static IEnumerable<Double> RangeUnpack(Range<Double> val, Double step)
/// Create a `float64` value.
/// </summary>
[EdgeQLFunction("to_float64", "std", "std::float64", false, false)]
public static Double ToFloat64(String s, String? fmt = null)
public static Double ToFloat64(String s, String? fmt)
=> default!;
/// <summary>
/// Round up to the nearest integer.
Expand Down Expand Up @@ -752,37 +752,37 @@ public static String StrReverse(String s)
/// Return string representation of the input value.
/// </summary>
[EdgeQLFunction("to_str", "std", "std::str", false, false)]
public static String ToStr(DateTimeOffset dt, String? fmt = null)
public static String ToStr(DateTimeOffset dt, String? fmt)
=> default!;
/// <summary>
/// Return string representation of the input value.
/// </summary>
[EdgeQLFunction("to_str", "std", "std::str", false, false)]
public static String ToStr(TimeSpan td, String? fmt = null)
public static String ToStr(TimeSpan td, String? fmt)
=> default!;
/// <summary>
/// Return string representation of the input value.
/// </summary>
[EdgeQLFunction("to_str", "std", "std::str", false, false)]
public static String ToStr(Int64 i, String? fmt = null)
public static String ToStr(Int64 i, String? fmt)
=> default!;
/// <summary>
/// Return string representation of the input value.
/// </summary>
[EdgeQLFunction("to_str", "std", "std::str", false, false)]
public static String ToStr(Double f, String? fmt = null)
public static String ToStr(Double f, String? fmt)
=> default!;
/// <summary>
/// Return string representation of the input value.
/// </summary>
[EdgeQLFunction("to_str", "std", "std::str", false, false)]
public static String ToStr(BigInteger d, String? fmt = null)
public static String ToStr(BigInteger d, String? fmt)
=> default!;
/// <summary>
/// Return string representation of the input value.
/// </summary>
[EdgeQLFunction("to_str", "std", "std::str", false, false)]
public static String ToStr(Decimal d, String? fmt = null)
public static String ToStr(Decimal d, String? fmt)
=> default!;
/// <summary>
/// Return string representation of the input value.
Expand All @@ -794,7 +794,7 @@ public static String ToStr(IEnumerable<String> array, String delimiter)
/// Return string representation of the input value.
/// </summary>
[EdgeQLFunction("to_str", "std", "std::str", false, false)]
public static String ToStr(Json json, String? fmt = null)
public static String ToStr(Json json, String? fmt)
=> default!;
/// <summary>
/// Convert a binary UTF-8 string to a text value.
Expand Down Expand Up @@ -824,13 +824,13 @@ public static String GetCurrentDatabase()
/// Return string representation of the input value.
/// </summary>
[EdgeQLFunction("to_str", "std", "std::str", false, false)]
public static String ToStr(DateTime dt, String? fmt = null)
public static String ToStr(DateTime dt, String? fmt)
=> default!;
/// <summary>
/// Return string representation of the input value.
/// </summary>
[EdgeQLFunction("to_str", "std", "std::str", false, false)]
public static String ToStr(DateOnly d, String? fmt = null)
public static String ToStr(DateOnly d, String? fmt)
=> default!;
/// <summary>
/// Encode given data as a base64 string
Expand All @@ -839,7 +839,7 @@ public static String ToStr(DateOnly d, String? fmt = null)
public static String Base64Encode(Byte[] data, Base64Alphabet alphabet = Base64Alphabet.standard, Boolean padding = true)
=> default!;
[EdgeQLFunction("CONCAT", "std", "std::str", false, false)]
public static String Concat(String l = null, String r = null)
public static String Concat(String l, String r)
=> default!;
/// <summary>
/// Return the smallest value of the input set.
Expand Down Expand Up @@ -884,7 +884,7 @@ public static IEnumerable<DateTimeOffset> RangeUnpack(Range<DateTimeOffset> val,
/// Create a `datetime` value.
/// </summary>
[EdgeQLFunction("to_datetime", "std", "std::datetime", false, false)]
public static DateTimeOffset ToDatetime(String s, String? fmt = null)
public static DateTimeOffset ToDatetime(String s, String? fmt)
=> default!;
/// <summary>
/// Create a `datetime` value.
Expand Down Expand Up @@ -1004,7 +1004,7 @@ public static Int16 BitLshift(Int16 val, Int64 n)
/// Create a `int16` value.
/// </summary>
[EdgeQLFunction("to_int16", "std", "std::int16", false, false)]
public static Int16 ToInt16(String s, String? fmt = null)
public static Int16 ToInt16(String s, String? fmt)
=> default!;
/// <summary>
/// Bitwise AND operator for 32-bit integers.
Expand Down Expand Up @@ -1052,7 +1052,7 @@ public static IEnumerable<Int32> RangeUnpack(Range<Int32> val, Int32 step)
/// Create a `int32` value.
/// </summary>
[EdgeQLFunction("to_int32", "std", "std::int32", false, false)]
public static Int32 ToInt32(String s, String? fmt = null)
public static Int32 ToInt32(String s, String? fmt)
=> default!;
/// <summary>
/// Return the array made from all of the input set elements.
Expand Down Expand Up @@ -1142,13 +1142,13 @@ public static Json JsonObjectPack(IEnumerable<ValueTuple<String, Json>> pairs)
/// Return the JSON value at the end of the specified path or an empty set.
/// </summary>
[EdgeQLFunction("json_get", "std", "std::json", false, true)]
public static Json? JsonGet(Json json, IEnumerable<String> path, Json? @default = default)
public static Json? JsonGet(Json json, IEnumerable<String> path, Json? @default)
=> default!;
/// <summary>
/// Return an updated JSON target with a new value.
/// </summary>
[EdgeQLFunction("json_set", "std", "std::json", false, true)]
public static Json? JsonSet(Json target, IEnumerable<String> path, Json? value = default, Boolean create_if_missing = true, JsonEmpty empty_treatment = JsonEmpty.ReturnEmpty)
public static Json? JsonSet(Json target, IEnumerable<String> path, Json? value, Boolean create_if_missing = true, JsonEmpty empty_treatment = JsonEmpty.ReturnEmpty)
=> default!;
/// <summary>
/// Return JSON value represented by the input *string*.
Expand All @@ -1157,10 +1157,10 @@ public static Json JsonObjectPack(IEnumerable<ValueTuple<String, Json>> pairs)
public static Json ToJson(String str)
=> default!;
[EdgeQLFunction("get_config_json", "cfg", "std::json", false, false)]
public static Json GetConfigJson(IEnumerable<String>? sources = null, String? max_source = null)
public static Json GetConfigJson(IEnumerable<String>? sources, String? max_source)
=> default!;
[EdgeQLFunction("CONCAT", "std", "std::json", false, false)]
public static Json Concat(Json l = default, Json r = default)
public static Json Concat(Json l, Json r)
=> default!;
/// <summary>
/// Return a version 1 UUID.
Expand All @@ -1175,7 +1175,7 @@ public static Guid UuidGenerateV1mc()
public static Guid UuidGenerateV4()
=> default!;
[EdgeQLFunction("range", "std", "range<std::anypoint>", false, false)]
public static Range<TPoint> Range<TPoint>(TPoint? lower = default, TPoint? upper = default, Boolean inc_lower = true, Boolean inc_upper = false, Boolean empty = false)
public static Range<TPoint> Range<TPoint>(TPoint? lower, TPoint? upper, Boolean inc_lower = true, Boolean inc_upper = false, Boolean empty = false)
where TPoint : struct
=> default!;
[EdgeQLFunction("multirange_unpack", "std", "range<std::int32>", true, false)]
Expand Down Expand Up @@ -1227,7 +1227,7 @@ public static Byte[] ToBytes(String s)
public static Byte[] Base64Decode(String data, Base64Alphabet alphabet = Base64Alphabet.standard, Boolean padding = true)
=> default!;
[EdgeQLFunction("CONCAT", "std", "std::bytes", false, false)]
public static Byte[] Concat(Byte[] l = null, Byte[] r = null)
public static Byte[] Concat(Byte[] l, Byte[] r)
=> default!;
/// <summary>
/// Return the isolation level of the current transaction.
Expand All @@ -1239,7 +1239,7 @@ public static TransactionIsolation GetTransactionIsolation()
/// Create a `cal::local_datetime` value.
/// </summary>
[EdgeQLFunction("to_local_datetime", "cal", "cal::local_datetime", false, false)]
public static DateTime ToLocalDatetime(String s, String? fmt = null)
public static DateTime ToLocalDatetime(String s, String? fmt)
=> default!;
/// <summary>
/// Create a `cal::local_datetime` value.
Expand Down Expand Up @@ -1272,7 +1272,7 @@ public static IEnumerable<DateTime> RangeUnpack(Range<DateTime> val, TimeSpan st
/// Create a `cal::local_date` value.
/// </summary>
[EdgeQLFunction("to_local_date", "cal", "cal::local_date", false, false)]
public static DateOnly ToLocalDate(String s, String? fmt = null)
public static DateOnly ToLocalDate(String s, String? fmt)
=> default!;
/// <summary>
/// Create a `cal::local_date` value.
Expand Down Expand Up @@ -1308,7 +1308,7 @@ public static IEnumerable<DateOnly> RangeUnpack(Range<DateOnly> val, TimeSpan st
/// Create a `cal::local_time` value.
/// </summary>
[EdgeQLFunction("to_local_time", "cal", "cal::local_time", false, false)]
public static TimeSpan ToLocalTime(String s, String? fmt = null)
public static TimeSpan ToLocalTime(String s, String? fmt)
=> default!;
/// <summary>
/// Create a `cal::local_time` value.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ private class ParsedParameter
public string? Type { get; init; }
public string[] Generics { get; set; } = Array.Empty<string>();
public List<string> GenericConditions { get; set; } = new();
public string? DefaultValue { get; set; } = "{}";
public string? DefaultValue { get; set; }
public bool Optional { get; set; }
}

Expand Down Expand Up @@ -361,7 +361,9 @@ await TypeUtils.BuildType(_client!, node, TypeModifier.SingletonType, StdLibOutp

parsedParameters[i] =
await ParseParameter(name, info, x.Parameter.Type!, x.Parameter.TypeModifier, i);
if (!string.IsNullOrEmpty(x.Parameter.Default) && x.Parameter.Default != "{}")
if (parsedParameters[i].Optional)
parsedParameters[i].DefaultValue = "{}";
else if (!string.IsNullOrEmpty(x.Parameter.Default))
parsedParameters[i].DefaultValue = await ParseDefaultAsync(x.Parameter.Default, info);
}

Expand Down Expand Up @@ -515,6 +517,9 @@ private static async ValueTask<ParsedParameter> ParseParameter(string? name, Typ

private static async Task<string> ParseDefaultAsync(string @default, TypeNode node)
{
if (@default == "{}")
return "null";

var result = await _client!.QuerySingleAsync<object>($"select {@default}");
return result switch
{
Expand Down

0 comments on commit 88b3329

Please sign in to comment.