public override string SelectorForDuplication(string pgType) { if (pgType.EqualsIgnoreCase("JSONB")) { return(JSONBLocator.Replace("d.", "")); } return($"CAST(ARRAY(SELECT jsonb_array_elements_text({RawLocator.Replace("d.", "")})) as {pgType})"); }
public DictionaryField(string dataLocator, Casing casing, EnumStorage enumStorage, MemberInfo[] members) : base(dataLocator, "JSONB", casing, members) { TypedLocator = $"CAST({RawLocator} as {PgType})"; _intermediateLocator = RawLocator.Replace("->>", "->"); var valueType = FieldType.GenericTypeArguments[1]; _isStringValue = valueType == typeof(string); _valuePgType = TypeMappings.GetPgType(valueType, enumStorage); }
public DictionaryField(string dataLocator, Casing casing, EnumStorage enumStorage, MemberInfo[] members) : base(dataLocator, "JSONB", casing, members) { TypedLocator = $"CAST({RawLocator} as {PgType})"; _intermediateLocator = RawLocator.Replace("->>", "->"); var valueType = FieldType.GenericTypeArguments[1]; _valueIsObject = valueType == typeof(object); _isStringValue = valueType == typeof(string); _valuePgType = PostgresqlProvider.Instance.GetDatabaseType(valueType, enumStorage); _enumStorage = enumStorage; }
private string locatorForField(string key) { if (_indexLocators.TryFind(key, out var locator)) { return(locator); } locator = $"{RawLocator.Replace("->>", "->")} ->> '{key}'"; if (!_valueIsObject) { locator = $"CAST({locator} as {_valuePgType})"; } _indexLocators = _indexLocators.AddOrUpdate(key, locator); return(locator); }
public override ISqlFragment CreateComparison(string op, ConstantExpression value, Expression memberExpression) { var key = memberExpression.As <MethodCallExpression>().Arguments[0].As <ConstantExpression>().Value; var locator = $"{RawLocator.Replace("->>", "->")} ->> '{key}'"; if (value.Value == null) { return(op == "=" ? (ISqlFragment) new IsNullFilter(this) : new IsNotNullFilter(this)); } else { if (_valueIsObject) { var pgType = TypeMappings.GetPgType(value.Value.GetType(), _enumStorage); locator = $"CAST({locator} as {pgType})"; } } var def = new CommandParameter(value); return(new ComparisonFilter(new WhereFragment(locator), def, op)); }
public override string SelectorForDuplication(string pgType) { // TODO -- get rid of the replacement here return($"CAST({RawLocator.Replace("d.", "")} as {pgType})"); }
public override string SelectorForDuplication(string pgType) { return($"CAST({RawLocator.Replace("d.", "")} as {pgType})"); }
public override string SelectorForDuplication(string pgType) { return(RawLocator.Replace("d.", "")); }
public override string SelectorForDuplication(string pgType) { // TODO -- eliminate the replace return(RawLocator.Replace("d.", "")); }