[DB-SIG] should precision and sign of decimal(0) be significant?

Vernon D. Cole vernondcole at gmail.com
Wed May 8 11:48:52 CEST 2013


I am working on code (django-mssql) where I found the following test:

##            expected = (
##                Decimal('0.00'),
##                Decimal('0.0'),
##                Decimal('-0.00'))
##
##            cur = con.cursor()

##            cur.paramstyle = 'format'  # a nonstandard extension -- VDC

##            cur.execute("SELECT %s as A, %s as B, %s as C", expected)
##
##            result = cur.fetchall()
##            self.assertEqual(result[0], expected)

I added the paramstyle alteration, to match the original test's assumption
-- that is not what I am asking about.  My question is: is this test
reasonable on it's face?

I personally think that all values of zero are equal, and the user should
have no expectation that neqative zero, or an accurately precise zero,
should be returned. My present code returns three copies of Decimal(0).

But someone must disagree, or this test would not have been written.

What is the feeling of the group?
--
Vernon Cole
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/db-sig/attachments/20130508/6a455a69/attachment.html>


More information about the DB-SIG mailing list