nim-lang / db_connector

Unified db connector in Nim
MIT License
18 stars 5 forks source link

mysql.nim fetch_field get wrong field type #7

Open autukill opened 2 years ago

autukill commented 2 years ago

Example

import db_mysql
import mysql

let db: DbConn = open("--ip--", "--user--", "--pwd--", "exhibition_db" )

discard mysql.query(PMySQL db, "select * from `products`");
var res:PRES = mysql.store_result(PMySQL db)
var numFields = int(mysql.num_fields(res))
echo "num fields=" , numFields
echo "count row=" , int(res.row_count)

for i in 0..<numFields:
  var field: PFIELD = mysql.fetch_field(res)
  echo "column=" , field.name , "  type=" , int(field.ftype)

# This code should output correct field type

Current Output

num fields=13
count row=6
column=ID  type=0
column=CreateTime  type=0
column=CreateBy  type=0
column=UpdateTime  type=0
column=UpdateBy  type=0
column=ProductName  type=0
column=ExhibitionAreaId  type=0
column=ExhibitionBoothId  type=0
column=CompanyName  type=0
column=PhotoId  type=0
column=ProductDesc  type=0
column=ProductAttachmentUrl  type=0
column=ProductAttachmentCode  type=0

Expected Output

num fields=13
count row=6
column=ID  type=3
column=CreateTime  type=12
column=CreateBy  type=253
column=UpdateTime  type=12
column=UpdateBy  type=253
column=ProductName  type=252
column=ExhibitionAreaId  type=3
column=ExhibitionBoothId  type=3
column=CompanyName  type=252
column=PhotoId  type=254
column=ProductDesc  type=252
column=ProductAttachmentUrl  type=252
column=ProductAttachmentCode  type=252

Additional Information

I tested macos, no problem.

nim --version
Nim Compiler Version 1.4.8 [Windows: amd64]
Compiled at 2021-05-25
Copyright (c) 2006-2021 by Andreas Rumpf

active boot switches: -d:release

win

c macos

ringabout commented 2 years ago

What's your DLL version and architecture(32 bit or 64 bit) on both platforms?

autukill commented 2 years ago

What's your DLL version and architecture(32 bit or 64 bit) on both platforms?

Windows C use 32 bit DLL "mysql-connector-c-6.1.11-win32" download from "https://downloads.mysql.com/archives/c-c/"

dumpbin /headers F:\Users\zuiza\Desktop\mysql-connector-c-6.1.11-win32\lib\libmysql.dll
Microsoft (R) COFF/PE Dumper Version 9.00.30729.01
Copyright (C) Microsoft Corporation.  All rights reserved.

Dump of file F:\Users\zuiza\Desktop\mysql-connector-c-6.1.11-win32\lib\libmysql.dll

PE signature found

File Type: DLL

FILE HEADER VALUES
             14C machine (x86)
               8 number of sections
        596CE31C time date stamp Tue Jul 18 00:17:32 2017
               0 file pointer to symbol table
               0 number of symbols
              E0 size of optional header
            2102 characteristics
                   Executable
                   32 bit word machine
                   DLL

Windows nim use 64 bit DLL "mysql-connector-c-6.1.11-winx64" download from "https://downloads.mysql.com/archives/c-c/"

dumpbin.exe /headers  F:\Repostitories\kanban-sale\libmysql.dll
Microsoft (R) COFF/PE Dumper Version 14.29.30038.1
Copyright (C) Microsoft Corporation.  All rights reserved.

Dump of file F:\Repostitories\kanban-sale\libmysql.dll

PE signature found

File Type: DLL

FILE HEADER VALUES
            8664 machine (x64)
               9 number of sections
        596CE0C2 time date stamp Tue Jul 18 00:07:30 2017
               0 file pointer to symbol table
               0 number of symbols
              F0 size of optional header
            2022 characteristics
                   Executable
                   Application can handle large (>2GB) addresses
                   DLL

macOS nim use "mysql-connector-c-6.1.11-macos10.12-x86_64" download from "https://downloads.mysql.com/archives/c-c/"