alialtun14 / odbc

Automatically exported from code.google.com/p/odbc
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Datetime field overflow #32

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.go test -mssrv=SERVERNAME.COM -msdb=DATABASENAME -msuser=USERNAME 
-mspass=YOURPASSWORD -v -run=MS -msdriver="ODBC Driver 11 for SQL Server"

What is the expected output? What do you see instead?
=== RUN TestMSSQLDatetime2Param
--- FAIL: TestMSSQLDatetime2Param (0.43 seconds)
        mssql_test.go:1007: SQLExecute: {22008} [Microsoft][ODBC Driver 11 for SQL Server]Datetime field overflow. Fractional second precision exceeds the scale specified in the parameter binding.

What version of the product are you using? On what operating system?
Ubuntu 12.04
Windows 7 + SQL Server 2012

Please provide any additional information below.
param.go 114
            // represented as yyyy-mm-dd hh:mm:ss.fff format in ms sql server
            if d.Nanosecond() % 1000000 > 0 {
                decimal = 7
            } else {
                decimal = 3
            }

Original issue reported on code.google.com by masatsug...@gmail.com on 22 Jan 2014 at 5:41

GoogleCodeExporter commented 9 years ago
What is your OS where your program runs? Linux or Windows?

Alex

Original comment by alex.bra...@gmail.com on 22 Jan 2014 at 10:24

GoogleCodeExporter commented 9 years ago
Linux

Original comment by masatsug...@gmail.com on 24 Jan 2014 at 12:20

GoogleCodeExporter commented 9 years ago
Sorry, I didn't have time to investigate your problems. But I will look into 
them as soon as I can. (I need to find a way to install "ODBC Driver 11 for SQL 
Server" driver on a Linux computer, to see the problem.)

Alex

Original comment by alex.bra...@gmail.com on 30 Jan 2014 at 10:29

GoogleCodeExporter commented 9 years ago
Can you, please, try this change:

diff --git a/param.go b/param.go
--- a/param.go
+++ b/param.go
@@ -8,7 +8,6 @@
    "code.google.com/p/odbc/api"
    "database/sql/driver"
    "fmt"
-   "runtime"
    "time"
    "unsafe"
 )
@@ -150,18 +149,17 @@
    }
    ps := make([]Parameter, n)
    // fetch param descriptions
-   if runtime.GOOS == "windows" {
-       // SQLDescribeParam is not implemented by freedts
-       for i := range ps {
-           p := &ps[i]
-           ret = api.SQLDescribeParam(h, api.SQLUSMALLINT(i+1),
-               &p.SQLType, &p.Size, &p.Decimal, &nullable)
-           if IsError(ret) {
-               // will try request without these descriptions
-               continue
-           }
-           p.isDescribed = true
+   for i := range ps {
+       p := &ps[i]
+       ret = api.SQLDescribeParam(h, api.SQLUSMALLINT(i+1),
+           &p.SQLType, &p.Size, &p.Decimal, &nullable)
+       if IsError(ret) {
+           // SQLDescribeParam is not implemented by freedts,
+           // it even fails for some statements on windows.
+           // Will try request without these descriptions
+           continue
        }
+       p.isDescribed = true
    }
    return ps, nil
 }

See if that helps. Thank you.

Alex

Original comment by alex.bra...@gmail.com on 4 Feb 2014 at 6:28

GoogleCodeExporter commented 9 years ago
I think this https://codereview.appspot.com/60540043/ will fix it. Please 
review. Thank you.

Alex

Original comment by alex.bra...@gmail.com on 6 Feb 2014 at 6:15

GoogleCodeExporter commented 9 years ago
All test passed. Thank you.

Original comment by masatsug...@gmail.com on 7 Feb 2014 at 12:50

GoogleCodeExporter commented 9 years ago
This issue was closed by revision 79ae99114308.

Original comment by alex.bra...@gmail.com on 7 Feb 2014 at 1:40