public void store_options_serializer_with_casing(Casing casing, string expectedUpdateFragment) { var storeOptions = new StoreOptions(); storeOptions.UseDefaultSerialization(casing: casing); var field = DuplicatedField.For <DuplicateFieldCasingTestDoc>(storeOptions, x => x.OtherId); field.UpdateSqlFragment().ShouldBe(expectedUpdateFragment); }
public DuplicatedFieldTests() { var storeOptions = new StoreOptions { }; storeOptions.Advanced.DuplicatedFieldEnumStorage = EnumStorage.AsInteger; theField = DuplicatedField.For <User>(storeOptions, x => x.FirstName); }
public void enum_field() { var field = DuplicatedField.For <Target>(EnumStorage.AsString, x => x.Color); field.UpsertArgument.DbType.ShouldBe(NpgsqlDbType.Varchar); field.UpsertArgument.PostgresType.ShouldBe("varchar"); var constant = Expression.Constant((int)Colors.Blue); field.GetValue(constant).ShouldBe(Colors.Blue.ToString()); }
public void storage_is_set_when_passed_in(EnumStorage storageMode, string expectedUpdateFragment) { var storeOptions = new StoreOptions(); storeOptions.Serializer(new JsonNetSerializer { EnumStorage = storageMode }); var field = DuplicatedField.For <Target>(storeOptions, x => x.Color); field.UpdateSqlFragment().ShouldBe(expectedUpdateFragment); }
public void store_options_schema_name_is_used_for_timestamptz(string schemaName, string expectedUpdateFragment) { var storeOptions = schemaName != null ? new StoreOptions { DatabaseSchemaName = schemaName } : new StoreOptions(); var field = DuplicatedField.For <Target>(storeOptions, x => x.DateOffset); field.UpdateSqlFragment().ShouldBe(expectedUpdateFragment); }
public void pg_type_is_used_for_string(string pgType, string expectedUpdateFragment) { var field = DuplicatedField.For <Target>(new StoreOptions(), x => x.String); field.PgType = pgType ?? field.PgType; field.UpdateSqlFragment().ShouldBe(expectedUpdateFragment); var expectedPgType = pgType ?? "varchar"; field.PgType.ShouldBe(expectedPgType); field.UpsertArgument.PostgresType.ShouldBe(expectedPgType); field.DbType.ShouldBe(NpgsqlDbType.Text); }
public void pg_type_is_used_for_guid(string pgType, string expectedUpdateFragment) { var field = DuplicatedField.For <Target>(EnumStorage.AsInteger, x => x.UserId); field.PgType = pgType ?? field.PgType; field.UpdateSqlFragment().ShouldBe(expectedUpdateFragment); var expectedPgType = pgType ?? "uuid"; field.PgType.ShouldBe(expectedPgType); field.UpsertArgument.PostgresType.ShouldBe(expectedPgType); field.DbType.ShouldBe(NpgsqlDbType.Uuid); }
public void pg_type_is_used_for_string_list(string pgType, string expectedUpdateFragment) { var field = DuplicatedField.For <ListTarget>(EnumStorage.AsInteger, x => x.TagsList); field.PgType = pgType ?? field.PgType; field.UpdateSqlFragment().ShouldBe(expectedUpdateFragment); var expectedPgType = pgType ?? "jsonb"; field.PgType.ShouldBe(expectedPgType); field.UpsertArgument.PostgresType.ShouldBe(expectedPgType); field.DbType.ShouldBe(NpgsqlDbType.Array | NpgsqlDbType.Text); }
public void enum_field() { var storeOptions = new StoreOptions(); storeOptions.Serializer(new JsonNetSerializer { EnumStorage = EnumStorage.AsString }); var field = DuplicatedField.For <Target>(storeOptions, x => x.Color); field.UpsertArgument.DbType.ShouldBe(NpgsqlDbType.Varchar); field.UpsertArgument.PostgresType.ShouldBe("varchar"); var constant = Expression.Constant((int)Colors.Blue); field.GetValue(constant).ShouldBe(Colors.Blue.ToString()); }
public void enum_field_allows_null() { var options = new StoreOptions(); options.Serializer(new JsonNetSerializer { EnumStorage = EnumStorage.AsString }); var field = DuplicatedField.For <Target>(options, x => x.Color); field.UpsertArgument.DbType.ShouldBe(NpgsqlDbType.Varchar); field.UpsertArgument.PostgresType.ShouldBe("varchar"); var constant = Expression.Constant(null); field.GetValueForCompiledQueryParameter(constant).ShouldBe(null); }
public DuplicatedFieldColumn(DuplicatedField field) : base(field.ColumnName, field.PgType, field.NotNull ? NotNullConstraint : NullConstraint) { CanAdd = true; _field = field; }
public DuplicatedFieldColumn(DuplicatedField field) : base(field.ColumnName, field.PgType) { CanAdd = true; _field = field; }
public static DuplicatedField <TModel> SimpleField(Expression <Func <TModel, object> > FieldExp) { return(DuplicatedField <TModel> .SimpleField(FieldExp)); }
public DuplicatedFieldColumn(DuplicatedField field) : base(field.ColumnName, field.PgType) { AllowNulls = !field.NotNull; _field = field; }
public void storage_is_set_when_passed_in(EnumStorage storageMode, string expectedUpdateFragment) { var field = DuplicatedField.For <Target>(storageMode, x => x.Color); field.UpdateSqlFragment().ShouldBe(expectedUpdateFragment); }