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

Correct SqliteType inference from string, DateOnly, TimeOnly #27213

Closed
xinbingyiran opened this issue Jan 19, 2022 · 1 comment · Fixed by #27291
Closed

Correct SqliteType inference from string, DateOnly, TimeOnly #27213

xinbingyiran opened this issue Jan 19, 2022 · 1 comment · Fixed by #27291
Assignees
Labels
area-adonet-sqlite closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. community-contribution customer-reported good first issue This issue should be relatively straightforward to fix. type-bug
Milestone

Comments

@xinbingyiran
Copy link

xinbingyiran commented Jan 19, 2022

Microsoft.Data.Sqlite 6.0.1
TargetFramework net6.0-windows

当我创建一个字符串类型的SqliteParameter时,我查询它的类型,得到的类型信息是 “SqliteType.Integer”

var p = new Microsoft.Data.Sqlite.SqliteParameter("Name","123");

后来我在源码中定位到了以下位置,这就有点不合适了吧

private static readonly Dictionary<Type, SqliteType> _sqliteTypeMapping =
new()
{
{ typeof(bool), SqliteType.Integer },
{ typeof(byte), SqliteType.Integer },
{ typeof(byte[]), SqliteType.Blob },
{ typeof(char), SqliteType.Text },
{ typeof(DateTime), SqliteType.Text },
{ typeof(DateTimeOffset), SqliteType.Text },
{ typeof(DBNull), SqliteType.Text },
{ typeof(decimal), SqliteType.Text },
{ typeof(double), SqliteType.Real },
{ typeof(float), SqliteType.Real },
{ typeof(Guid), SqliteType.Text },
{ typeof(int), SqliteType.Integer },
{ typeof(long), SqliteType.Integer },
{ typeof(sbyte), SqliteType.Integer },
{ typeof(short), SqliteType.Integer },
{ typeof(string), SqliteType.Integer },
{ typeof(TimeSpan), SqliteType.Text },
{ typeof(uint), SqliteType.Integer },
{ typeof(ulong), SqliteType.Integer },
{ typeof(ushort), SqliteType.Integer }
};

@roji
Copy link
Member

roji commented Jan 19, 2022

Google Translate:

When I create a SqliteParameter of type string, I query its type, and the type info I get is "SqliteType.Integer"
...
Later, I located the following location in the source code, which is a bit inappropriate.

/cc @bricelam

@bricelam bricelam added good first issue This issue should be relatively straightforward to fix. type-bug labels Jan 21, 2022
@bricelam bricelam self-assigned this Jan 21, 2022
@ajcvickers ajcvickers added this to the 7.0.0 milestone Jan 22, 2022
@bricelam bricelam added the closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. label Feb 4, 2022
@roji roji assigned roji and bricelam and unassigned bricelam and roji Feb 23, 2022
@roji roji changed the title string 类型参数 获取到的SqliteType是Integer Correct SqliteType inference from string, DateOnly, TimeOnly Feb 23, 2022
@ajcvickers ajcvickers modified the milestones: 7.0.0, 7.0.0-preview3 Mar 31, 2022
@ajcvickers ajcvickers modified the milestones: 7.0.0, 7.0.0-preview6 Jun 20, 2022
@ajcvickers ajcvickers modified the milestones: 7.0.0-preview6, 7.0.0 Nov 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-adonet-sqlite closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. community-contribution customer-reported good first issue This issue should be relatively straightforward to fix. type-bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants