-
Notifications
You must be signed in to change notification settings - Fork 342
BIGINT(20)/INT(20) type has wrong ColumnSize in SchemaTable #1062
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
Comments
After some more investigation it seems that most (none?) of the ColumnSize returned by GetSchemaTable() are correct. I would expect the ColumnSize to match the number of bytes specified here: https://dev.mysql.com/doc/refman/8.0/en/storage-requirements.html For example: DateTime returns a ColumnSize of 19 instead of 8. I am interpreting ColumnSize wrong? Or is this a bug? |
It's currently intentional to show "display width" in this column. using var connection = new MySqlConnection(cs.ConnectionString);
connection.Execute(@"drop table if exists test;
create table test(a int(5), b int(10), c bigint(15), d bigint(20));
insert into test values(1, 2, 3, 4);");
using var reader = connection.ExecuteReader("select * from test");
However the numeric display width is now deprecated; https://dev.mysql.com/doc/refman/8.0/en/numeric-type-attributes.html:
Moreover, users who just use
I don't have expectation that
I think so. Technically, it's the value returned by the MySQL Server for the |
I was basing my assumption on this: https://docs.microsoft.com/en-us/dotnet/api/system.data.datatablereader.getschematable?view=net-5.0. Which states: Because this is an implementation of DataTableReader.GetSchemaTable() it shouldn't matter which database I connect to. I should expect the same schematable the same table definition for mysql, posgresql or mssql. |
Well... technically... the size of a But besides that, characters != bytes, so I'm not understanding the relevance to a numeric column type yet. |
I haven't checked those databases yet, but it sounds like something worth testing so I've opened an issue for it: mysql-net/AdoNetApiTest#223. |
Awesome! Thanks for your responses. |
MySqlConnector returns the "length" values returned by the MySQL Server; this is by design. |
I would expect the columnsize of bigint and int to be 8 and 4 respectively.
But calling MySqlDataReader.GetSchemaTable() return ColumnSize of 20. Apparently this is a 'known' quirkiness in MySql (https://stackoverflow.com/questions/3135804/types-in-mysql-bigint20-vs-int20)
The text was updated successfully, but these errors were encountered: