Open yaitskov opened 4 years ago
+=.
is the operator for addition. What behavior do you expect here?
Setting to 0
is definitely weird, but I suspect it's a MySQL casting/coercion thing.
mysql> select 'a' + 'b';
+-----------+
| 'a' + 'b' |
+-----------+
| 0 |
+-----------+
1 row in set, 2 warnings (0.00 sec)
So I think this is generating the SQL you're asking for (possibly unintentionally), but it's having a somewhat surprising result. Postgresql fails with a type mismatch error, and sqlite
does the same as mysql:
sqlite> select 'a' + 'b';
0
I think we can possibly make this safer (but more inconvenient) by requiring a Num
constraint on these functions since they don't really operate sensibly outside of those types.
Oh I see. I wanted just override field with new value. It was hard to find info how build Update object.
Another option is to use concat for string ;)
To overwrite a field value, you can use the (=.)
operator.
+=.
can't currently be different for strings and numbers, and I don't think I want to introduce overloading like that - if I did, then you'd have submitted a slightly different bug report :)
I guess this could be closed?
Hi,
Up on record update/upsert (if update) new value is discarded and column value in db gets "0".
Checking db
GHCI 8.6.5 windows 10 and mysql 5.6.39 on docker
mysql-haskell-0.8.4.2 persistent-2.9.2