コード例 #1
0
ファイル: ArrayField.cs プロジェクト: jeffdoolittle/marten
        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})");
        }
コード例 #2
0
ファイル: DictionaryField.cs プロジェクト: srasch/marten
        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);
        }
コード例 #3
0
        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;
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        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));
        }
コード例 #6
0
 public override string SelectorForDuplication(string pgType)
 {
     // TODO -- get rid of the replacement here
     return($"CAST({RawLocator.Replace("d.", "")} as {pgType})");
 }
コード例 #7
0
 public override string SelectorForDuplication(string pgType)
 {
     return($"CAST({RawLocator.Replace("d.", "")} as {pgType})");
 }
コード例 #8
0
ファイル: StringField.cs プロジェクト: tonykaralis/marten
 public override string SelectorForDuplication(string pgType)
 {
     return(RawLocator.Replace("d.", ""));
 }
コード例 #9
0
 public override string SelectorForDuplication(string pgType)
 {
     // TODO -- eliminate the replace
     return(RawLocator.Replace("d.", ""));
 }