diff --git a/condition/field_value.go b/condition/field_value.go index 9aa7007..a4c5cfa 100644 --- a/condition/field_value.go +++ b/condition/field_value.go @@ -62,29 +62,21 @@ func (value NumericFieldValue[TModel, TAttribute]) getType() numeric { } // Plus sums other to value -// -// Warning: in PostgreSQL the value received by parameter could be casted to integer func (value *NumericFieldValue[TModel, TAttribute]) Plus(other float64) *NumericFieldValue[TModel, TAttribute] { return value.addOperation(other, "+") } // Minus subtracts other from the value -// -// Warning: in PostgreSQL the value received by parameter could be casted to integer func (value *NumericFieldValue[TModel, TAttribute]) Minus(other float64) *NumericFieldValue[TModel, TAttribute] { return value.addOperation(other, "-") } // Times multiplies value by other -// -// Warning: in PostgreSQL the value received by parameter could be casted to integer func (value *NumericFieldValue[TModel, TAttribute]) Times(other float64) *NumericFieldValue[TModel, TAttribute] { return value.addOperation(other, "*") } // Divided divides value by other -// -// Warning: in PostgreSQL the value received by parameter could be casted to integer func (value *NumericFieldValue[TModel, TAttribute]) Divided(other float64) *NumericFieldValue[TModel, TAttribute] { return value.addOperation(other, "/") } diff --git a/test/update_test.go b/test/update_test.go index 3603123..11eeba5 100644 --- a/test/update_test.go +++ b/test/update_test.go @@ -702,18 +702,26 @@ func (ts *UpdateIntTestSuite) TestUpdateDynamicWithFunction() { ts.db, conditions.Product.Bool.Is().False(), ).Set( - conditions.Product.Int.Set().Dynamic(conditions.Product.Float.Value().Plus(1)), + conditions.Product.Int.Set().Dynamic(conditions.Product.Float.Value().Plus(1.1)), ) - ts.Require().NoError(err) - ts.Equal(int64(1), updated) - productReturned, err := cql.Query[models.Product]( - ts.db, - conditions.Product.Int.Is().Eq(2), - ).FindOne() - ts.Require().NoError(err) + if getDBDialector() == cqlSQL.Postgres && err != nil { + // cockroachdb + ts.ErrorContains(err, "unsupported binary operator: + (desired ) (SQLSTATE 22023); method: Set") + } else { + ts.Require().NoError(err) + ts.Equal(int64(1), updated) + + productReturned, err := cql.Query[models.Product]( + ts.db, + conditions.Product.Int.Is().Eq(2), + ).FindOne() + + ts.Require().NoError(err) + + ts.Equal(product1.ID, productReturned.ID) + ts.Equal(2, productReturned.Int) + ts.NotEqual(product1.UpdatedAt.UnixMicro(), productReturned.UpdatedAt.UnixMicro()) + } - ts.Equal(product1.ID, productReturned.ID) - ts.Equal(2, productReturned.Int) - ts.NotEqual(product1.UpdatedAt.UnixMicro(), productReturned.UpdatedAt.UnixMicro()) }