Skip to content

Queries written with identifier names wrapped in escape characters do not map correctly to objects #334

@seb-bartholomew-amcs

Description

@seb-bartholomew-amcs

To recreate, prepare a SQL query
( I know the official character to be used is double-quotes but sqlite does support square brackets as well as grave accent characters - https://www.sqlite.org/lang_keywords.html - so I've included some here )

Query:
string query = @"
SELECT
""AColumn""
FROM
[ATable]
";

And an object to output result as:

public class ATable
{
public string AColumn { get; set; }
}

Run query via SQLite.Net (not sure if this issue is specific to -PCL only):

var command = connection.CreateCommand(query);
var results = command.ExecuteQuery();

Expected:

Each result in results has a populated AColumn property.

Actual:

All AColumn properties have a null value.

Reason:

SQLite.Net.SQLiteCommand.ExecuteDeferredQuery(TableMapping map) method makes a call to _sqlitePlatform.SQLiteApi.ColumnName16() to get the column names returned by the Query. The column names returned by this call INCLUDE the escape characters used when defining the column. When this column name is passed to map.FindColumn() the mapping fails as the property name on the object does not include the escape characters.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions