ClickHouse.Client icon indicating copy to clipboard operation
ClickHouse.Client copied to clipboard

Data reader `GetSchemaTable()` returns incorrectly-typed data

Open MaceWindu opened this issue 3 years ago • 3 comments

Column type is not configured in code and have default value (string).

E.g. AllowDBNull is string instead of bool.

https://github.com/DarkWanderer/ClickHouse.Client/blob/master/ClickHouse.Client/Utility/SchemaDescriber.cs

MaceWindu avatar Jun 03 '22 14:06 MaceWindu

Hi @MaceWindu

Can you provide more details? (& ideally the list of columns where you see mismatch)

DarkWanderer avatar Jun 18 '22 10:06 DarkWanderer

Sure:

using var cn = new ClickHouseConnection(cs);
			cn.Open();
			using var cmd = cn.CreateCommand();
			cmd.CommandText = "select * from system.tables";
			using var rd = cmd.ExecuteReader();
			var schema = rd.GetSchemaTable();
			if (schema.Rows[0]["AllowDBNull"] is not bool)
				throw new InvalidOperationException("AllowDBNull should be bool");

MaceWindu avatar Jun 18 '22 10:06 MaceWindu

I think you can use property types here for reference

https://docs.microsoft.com/en-us/dotnet/api/system.data.datacolumn?view=net-6.0

MaceWindu avatar Jun 18 '22 10:06 MaceWindu