// TODO -- there's duplication here w/ DocumentStorage private IEnumerable<ISqlFragment> extraFilters(ISqlFragment query) { yield return toBasicWhere(); if (_mapping.DeleteStyle == DeleteStyle.SoftDelete && !query.Contains(SchemaConstants.DeletedColumn)) yield return ExcludeSoftDeletedFilter.Instance; if (_mapping.Parent.TenancyStyle == TenancyStyle.Conjoined && !query.SpecifiesTenant()) yield return new TenantWhereFragment(); }
private IEnumerable <ISqlFragment> extraFilters(ISqlFragment query) { if (_mapping.DeleteStyle == DeleteStyle.SoftDelete && !query.Contains(SchemaConstants.DeletedColumn)) { yield return(ExcludeSoftDeletedFilter.Instance); } if (TenancyStyle == TenancyStyle.Conjoined && !query.SpecifiesTenant()) { yield return(CurrentTenantFilter.Instance); } }
public static bool SpecifiesEventArchivalStatus(this ISqlFragment query) { if (query.Flatten().OfType <IArchiveFilter>().Any()) { return(true); } if (query.Contains(IsArchivedColumn.ColumnName)) { return(true); } return(false); }
public ISqlFragment FilterDocuments(QueryModel model, ISqlFragment query) { if (query.Flatten().OfType <IArchiveFilter>().Any()) { return(query); } if (query.Contains(IsArchivedColumn.ColumnName)) { return(query); } return(query.CombineAnd(IsNotArchivedFilter.Instance)); }
private IEnumerable <ISqlFragment> extraFilters(ISqlFragment query) { yield return(toBasicWhere()); if (DeleteStyle == DeleteStyle.SoftDelete && !query.Contains(DocumentMapping.DeletedColumn)) { yield return(DocumentMapping.ExcludeSoftDeletedDocuments()); } if (Parent.TenancyStyle == TenancyStyle.Conjoined && !query.SpecifiesTenant()) { yield return(new TenantWhereFragment()); } }
public void ConfigureCommand(CommandBuilder builder, IMartenSession session) { var patchParam = builder.AddJsonParameter(_serializer.ToCleanJson(_patch)); if (_patch.TryGetValue("value", out var document)) { var value = PossiblyPolymorhpic ? _serializer.ToJsonWithTypes(document) : _serializer.ToJson(document); var copy = new Dictionary <string, object>(); foreach (var item in _patch) { copy.Add(item.Key, item.Value); } copy["value"] = VALUE_LOOKUP; var patchJson = _serializer.ToJson(copy); var replacedValue = patchJson.Replace($"\"{VALUE_LOOKUP}\"", value); patchParam = builder.AddJsonParameter(replacedValue); } var versionParam = builder.AddParameter(CombGuidIdGeneration.NewGuid(), NpgsqlDbType.Uuid); builder.Append("update "); builder.Append(_storage.TableName.QualifiedName); builder.Append(" as d set data = "); builder.Append(_transform.Identifier.QualifiedName); builder.Append("(data, :"); builder.Append(patchParam.ParameterName); builder.Append("), "); builder.Append(SchemaConstants.LastModifiedColumn); builder.Append(" = (now() at time zone 'utc'), "); builder.Append(SchemaConstants.VersionColumn); builder.Append(" = :"); builder.Append(versionParam.ParameterName); if (!_fragment.Contains("where")) { builder.Append(" where "); } else { builder.Append(" "); } _fragment.Apply(builder); applyUpdates(builder, _fragment); }