tinyInt
yucikala opened this issue · 3 comments
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);
I found, that tinyint(1) is always interpreted as boolean. I change db model...
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.
you can also set TreatTinyAsBoolean by using MySqlConnectionStringBuilder object