Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: When querying the tinyint(1) type field in mysql, the query result returns a bool value, but the actual data type is a numeric type. #1356

Open
happyJonychen opened this issue Apr 30, 2024 · 0 comments

Comments

@happyJonychen
Copy link

happyJonychen commented Apr 30, 2024

Chat2DB Version

1.0.7

Describe the bug

Problem Description

ddl of table

CREATE TABLE `test` (
  `id` int(11) NOT NULL,
  `test` tinyint(1) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4

data in table

image

Check for phrases

select * from test

Chat2DB results of the

image

Solution suggestions

method one

In mysql, by default, the display length of the tinyint type is 1 (signed), which defaults to representing a Boolean value. You can link out the splicing parameters in mysql.

tinyInt1isBit=false

method two

Use the get method according to the field data type. Not all use rs.getObject. For example, for tinyint type, use rs.getInt to get the normal value. The corresponding code position:


image

@happyJonychen happyJonychen added the bug Something isn't working label Apr 30, 2024
@miahemu miahemu added Mysql-bug and removed bug Something isn't working labels May 7, 2024
@miahemu miahemu changed the title Bug: 在mysql中查询tinyint(1)类型字段,查询结果返回bool值,但实际数据类型为数值类型 Bug: When querying the tinyint(1) type field in mysql, the query result returns a bool value, but the actual data type is a numeric type. May 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants