QueryInterface处理PostgreSQL的smallint错误(QueryInterface handling smallint column of PostgreSQL is wrong) #2181

Open
opened 2022-09-30 02:50:08 +00:00 by iveteran · 2 comments

QueryInterface处理PostgreSQL的bigint和smallint错误

  1. 将smallint处理成slice(Converts smallint value to slice)
  2. 将bigint(64bits)处理成int32(Converts bigint value to int32, expect int64)

localhost # \d tbl_test_table
Table "public.tbl_test_table"
Column | Type | Collation | Nullable | Default
-----------+------------------------+-----------+----------+--------------------------------------------
id | bigint | | not null | nextval('tbl_test_table_id_seq'::regclass)
name | character varying(64) | | |
full_name | character varying(128) | | |
summary | character varying(200) | | |
status | smallint | | |
int_value | integer | | |

localhost # select * from tbl_test_table;
id | name | full_name | summary | status | int_value
----+-------+-------------+---------+--------+-----------
1 | yuu | hello yuu | [null] | 1 | 100
2 | zhang | hello zhang | [null] | 10 | 110

$ go run main.go

items: [map[full_name:hello yuu id:1 int_value:100 name:yuu status:[49]] map[full_name:hello zhang id:2 int_value:110 name:zhang status:[49 48]]]
column id type: int32, int32
column status type: , slice
column int_value type: int32, int32

Here expect status value are 1 and 10, but got [49] and [49 48]

PostgreSQL version 12.10
Go version: 1.14.2
github.com/lib/pq v1.10.2
xorm.io/xorm v1.3.2

the test code and demo table are attached

QueryInterface处理PostgreSQL的bigint和smallint错误 1) 将smallint处理成slice(Converts smallint value to slice) 2) 将bigint(64bits)处理成int32(Converts bigint value to int32, expect int64) localhost # \d tbl_test_table Table "public.tbl_test_table" Column | Type | Collation | Nullable | Default -----------+------------------------+-----------+----------+-------------------------------------------- id | bigint | | not null | nextval('tbl_test_table_id_seq'::regclass) name | character varying(64) | | | full_name | character varying(128) | | | summary | character varying(200) | | | status | smallint | | | int_value | integer | | | localhost # select * from tbl_test_table; id | name | full_name | summary | status | int_value ----+-------+-------------+---------+--------+----------- 1 | yuu | hello yuu | [null] | 1 | 100 2 | zhang | hello zhang | [null] | 10 | 110 $ go run main.go >> items: [map[full_name:hello yuu id:1 int_value:100 name:yuu status:[49]] map[full_name:hello zhang id:2 int_value:110 name:zhang status:[49 48]]] column id type: int32, int32 column status type: , slice column int_value type: int32, int32 Here expect status value are 1 and 10, but got [49] and [49 48] PostgreSQL version 12.10 Go version: 1.14.2 github.com/lib/pq v1.10.2 xorm.io/xorm v1.3.2 the test code and demo table are attached
Author
No description provided.
Author

浮点数据也有问题,一个price列返回 price:[49 50]、price:[49 48 48]等数据!

浮点数据也有问题,一个price列返回 price:[49 50]、price:[49 48 48]等数据!
Sign in to join this conversation.
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: xorm/xorm#2181
No description provided.