Uploaded image for project: 'CUBRID APIs'
  1. CUBRID APIs
  2. APIS-371

CUBRID python driver should coerse values given with e- or e+ to NUMERIC

    Details

    • Type: New Feature
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: Python 9.1.0.p1
    • Component/s: Python Driver
    • Labels:
      None
    • Environment:

      Any

      Description

      Assume you have a field with NUMERIC data type and you want to insert the following values using prepared statements:

      5.000025e+4 or 5.3e-1

      This values cannot be coerced to NUMERIC. Same goes for "e-" values.

        Activity

        Hide
        lilin54 李林 (Inactive) added a comment -

        For now, CUBRID engineer can't parse a string such as '5.000025e+4' to Numeric or Float type,
        you can see CUBRID issue at http://bts4.nhncorp.com/nhnbts/browse/CUBRIDSUS-9477.

        This feature can'be supported now, but if CUBRID engineer fix that issue, this feature can be supported automatically.

        Show
        lilin54 李林 (Inactive) added a comment - For now, CUBRID engineer can't parse a string such as '5.000025e+4' to Numeric or Float type, you can see CUBRID issue at http://bts4.nhncorp.com/nhnbts/browse/CUBRIDSUS-9477 . This feature can'be supported now, but if CUBRID engineer fix that issue, this feature can be supported automatically.
        Hide
        ryin005 Ray Yin added a comment -
        • Environment:
          • OS: Linux 64
          • Server Version: CUBRID 9.1.0.0212
          • Driver Version: cubrid-python-9.1.0.p1.tar.gz (2013-05-22)
        • Test Case:
          import unittest
          import CUBRIDdb
          import time
          import locale
          from xml.dom import minidom
          
          class apis_371_test(unittest.TestCase):
              def setUp(self):
                      conStr="CUBRID:localhost:33188:test_python:::"
                      self.con = CUBRIDdb.connect(conStr, "dba","")        
                      self.cur = self.con.cursor()
                      self.con.set_autocommit(True)
                      self.cur.execute("DROP TABLE IF EXISTS numeric_db")
                      self.cur.execute("CREATE TABLE numeric_db(col_1 numeric)")
          
              def tearDown(self):
                      self.cur.close
                      self.con.close
                      
              def test_insert_numeric(self):
                      sqlInsert = "insert into numeric_db(col_1) values (5.000025e+4)"
                      self.cur.execute(sqlInsert)
                      sqlSelect = "select * from numeric_db"
                      self.cur.execute(sqlSelect)
                      dataReturn = self.cur.fetchone()
                      self.assertEquals(50000, dataReturn[0])
                      
                      sqlInsert = "insert into numeric_db(col_1) values (43.32e-1)"
                      self.cur.execute(sqlInsert)
                      sqlSelect = "select * from numeric_db"
                      self.cur.execute(sqlSelect)
                      dataReturn = self.cur.fetchone()
                      dataReturn = self.cur.fetchone()
                      self.assertEquals(4, dataReturn[0])
          
          if __name__ == '__main__':
              suite = unittest.TestLoader().loadTestsFromTestCase(apis_371_test)
              unittest.TextTestRunner(verbosity=2).run(suite)
          
        • Result: Pass
        Show
        ryin005 Ray Yin added a comment - Environment: OS: Linux 64 Server Version: CUBRID 9.1.0.0212 Driver Version: cubrid-python-9.1.0.p1.tar.gz (2013-05-22) Test Case: import unittest import CUBRIDdb import time import locale from xml.dom import minidom class apis_371_test(unittest.TestCase): def setUp(self): conStr="CUBRID:localhost:33188:test_python:::" self.con = CUBRIDdb.connect(conStr, "dba","") self.cur = self.con.cursor() self.con.set_autocommit(True) self.cur.execute("DROP TABLE IF EXISTS numeric_db") self.cur.execute("CREATE TABLE numeric_db(col_1 numeric)") def tearDown(self): self.cur.close self.con.close def test_insert_numeric(self): sqlInsert = "insert into numeric_db(col_1) values (5.000025e+4)" self.cur.execute(sqlInsert) sqlSelect = "select * from numeric_db" self.cur.execute(sqlSelect) dataReturn = self.cur.fetchone() self.assertEquals(50000, dataReturn[0]) sqlInsert = "insert into numeric_db(col_1) values (43.32e-1)" self.cur.execute(sqlInsert) sqlSelect = "select * from numeric_db" self.cur.execute(sqlSelect) dataReturn = self.cur.fetchone() dataReturn = self.cur.fetchone() self.assertEquals(4, dataReturn[0]) if __name__ == '__main__': suite = unittest.TestLoader().loadTestsFromTestCase(apis_371_test) unittest.TextTestRunner(verbosity=2).run(suite) Result: Pass

          People

          • Assignee:
            lilin54 李林 (Inactive)
            Reporter:
            ovidiu.veliscu Veliscu Ovidiu
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: