Re: Should Model.save() fix incorrect types that happen to save correctly?

2017-02-15 Thread Robert Roskam
+1, documenting in this case seems to be the most appropriate. Robert Roskam On Monday, February 13, 2017 at 10:51:59 AM UTC-5, Adam Johnson wrote: > > What do you think? Absent a better suggestion, we could document this >> pitfall so that there's something to point to when related tickets

Re: Should Model.save() fix incorrect types that happen to save correctly?

2017-02-14 Thread Josh Smeaton
I posted on the ticket before reading this thread. Whoops. As mentioned above it's impossible to always convert user input into the output provided by the database without doing a round trip, because there are driver data adapters, and django converters that both get a chance at modifying the

Re: Should Model.save() fix incorrect types that happen to save correctly?

2017-02-14 Thread Marc Tamlyn
Agreed - ensuring that this works in the general case is not reliable. On 13 February 2017 at 15:51, Adam Johnson wrote: > What do you think? Absent a better suggestion, we could document this >> pitfall so that there's something to point to when related tickets come in. > > >

Re: Should Model.save() fix incorrect types that happen to save correctly?

2017-02-13 Thread Adam Johnson
> > What do you think? Absent a better suggestion, we could document this > pitfall so that there's something to point to when related tickets come in. +1, as Aymeric points out the more complex fields probably won't work with coercion-on-set. On 13 February 2017 at 15:27, charettes

Re: Should Model.save() fix incorrect types that happen to save correctly?

2017-02-13 Thread charettes
> What do you think? Absent a better suggestion, we could document this pitfall so that there's something to point to when related tickets come in. I also think this is the most appropriate solution. Le lundi 13 février 2017 09:57:49 UTC-5, Tim Graham a écrit : > > Once in a while, there's a

Re: Should Model.save() fix incorrect types that happen to save correctly?

2017-02-13 Thread Aymeric Augustin
Hello, I think this falls in the realm of duck typing. In Python, the programmer is allowed to use one data type instead of another — str instead of decimal.Decimal in this example — as long as they’re “sufficiently compatible” (where “sufficiently” depends on chance and taste, among others).

Re: Should Model.save() fix incorrect types that happen to save correctly?

2017-02-13 Thread Florian Apolloner
On Monday, February 13, 2017 at 3:57:49 PM UTC+1, Tim Graham wrote: > > What do you think? Absent a better suggestion, we could document this > pitfall so that there's something to point to when related tickets come in. > Seems sensible. -- You received this message because you are

Should Model.save() fix incorrect types that happen to save correctly?

2017-02-13 Thread Tim Graham
Once in a while, there's a ticket about this behavior: m = Model(decimal='12.9') m.save() self.assertEqual(m.decimal, '12.9') m.refresh_from_db() self.assertEqual(m.decimal, Decimal('12.9')) That is, you can create a model with an incorrect type and it won't be fixed until you refresh the