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

tinyInt #95

Closed
yucikala opened this issue Oct 20, 2022 · 3 comments
Closed

tinyInt #95

yucikala opened this issue Oct 20, 2022 · 3 comments

Comments

@yucikala
Copy link

I have a simple datatable. One column is tinyInt 1.
All exported rows has value 1 - but original data has 1,2,3... Why are the dump incorrect? What I have wrong?

output:
DROP TABLE IF EXISTS urop_degree;
CREATE TABLE IF NOT EXISTS urop_degree (
id int(11) NOT NULL AUTO_INCREMENT,
degree char(50) NOT NULL DEFAULT '',
sequence tinyint(3) DEFAULT NULL,
lodge tinyint(1) NOT NULL DEFAULT '0',
picture char(50) DEFAULT NULL,
active tinyint(1) NOT NULL DEFAULT '1',
svetlo1_c tinyint(3) unsigned DEFAULT NULL,
svetlo1_vc tinyint(3) unsigned DEFAULT NULL,
svetlo2_c tinyint(3) unsigned DEFAULT NULL,
svetlo2_vc tinyint(3) unsigned DEFAULT NULL,
svetlo3_c tinyint(3) unsigned DEFAULT NULL,
svetlo3_vc tinyint(3) unsigned DEFAULT NULL,
svetlo4_c tinyint(3) unsigned DEFAULT NULL,
svetlo4_vc tinyint(3) unsigned DEFAULT NULL,
navic_c tinyint(3) unsigned DEFAULT NULL,
navic_vc tinyint(3) unsigned DEFAULT NULL,
svetlo1_op tinyint(3) unsigned DEFAULT NULL,
svetlo2_op tinyint(3) unsigned DEFAULT NULL,
svetlo3_op tinyint(3) unsigned DEFAULT NULL,
svetlo4_op tinyint(3) unsigned DEFAULT NULL,
navic_op tinyint(3) unsigned DEFAULT NULL,
text text,
PRIMARY KEY (id),
KEY sequence (sequence)
) ENGINE=MyISAM AUTO_INCREMENT=28 DEFAULT CHARSET=cp1250 ROW_FORMAT=FIXED;

--
-- Dumping data for table urop_degree

/*!40000 ALTER TABLE urop_degree DISABLE KEYS /;
INSERT INTO urop_degree(id,degree,lodge) VALUES
(1,'Sagamor Čikala',1),
(2,'Orlí Sagamor Čikala',1),
(4,'Sagamor',1),
/
!40000 ALTER TABLE urop_degree ENABLE KEYS */;

origin data:
INSERT INTO urop_degree VALUES ('Sagamor Čikala', 5, 2, 'ml_sagamor_cikala.gif', 1, 6, 0, 6, 0, 6, 0, 6, 0, 0, 0, 0, 0, 0, 0, 0, 'Je ten, kdo je starý 14 let (hranice může být náčelníkem kmene snížena).');
INSERT INTO urop_degree VALUES ('Orlí Sagamor Čikala', 6, 2, 'ml_orli_sagamor_cikala.gif', 1, 6, 0, 6, 0, 6, 0, 6, 0, 12, 0, 0, 0, 0, 0, 0, NULL);
INSERT INTO urop_degree VALUES ('Sagamor', 3, 1, 'vl_sagamor.gif', 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 6, 6, 6, 0, NULL);

@yucikala
Copy link
Author

I found, that tinyint(1) is always interpreted as boolean. I change db model...

@adriancs2
Copy link
Member

You can apply a connection string option to revert this

TreatTinyAsBoolean=false;

For example:

server=127.0.0.1;user=root;pwd=1234;databaset=test;treattinyasboolean=false;

According to the documentation:
https://dev.mysql.com/doc/connector-net/en/connector-net-8-0-connection-options.html

TreatTinyAsBoolean , Treat Tiny As Boolean
Default: true

Setting this value to false causes TINYINT(1) to be treated as an INT. See Numeric Data Type Syntax for a further explanation of the TINYINT and BOOL data types.

@adriancs2
Copy link
Member

Referrence: https://dev.mysql.com/doc/dev/connector-net/6.10/html/T_MySql_Data_MySqlClient_MySqlConnectionStringBuilder.htm

you can also set TreatTinyAsBoolean by using MySqlConnectionStringBuilder object

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants