Skip to content
This repository was archived by the owner on May 9, 2020. It is now read-only.
This repository was archived by the owner on May 9, 2020. It is now read-only.

Duplicate citation of table name in FbHistoryRepository.ExistsSql #47

@krilbe

Description

@krilbe

The issue

SQL generated to check existence of a table puts single quotes around the tabel name string literal returned by stringTypeMapping.GenerateSqlLiteral(TableName), which it should not.

Steps to reproduce

We encounter this when trying to execute migration, when an attempt is made to check for the table __EFMigrationsHistory. This is SQL we get:

SELECT COUNT(*)
FROM rdb$relations r
WHERE
    COALESCE(r.rdb$system_flag, 0) = 0
    AND
    rdb$view_blr IS NULL
    AND
    rdb$relation_name = '_UTF8'__EFMigrationsHistory''

Notice that there are single quotes around the table name itself (from GenerateSqlLiteral(...)) as well as around the _UTF8 refixed complete literal.

Further technical details

EntityFrameworkCore.FirebirdSql version: 2.1.4

Suggested fix

In FbHistoryRepository.cs, this code appears:

                return $@"
SELECT COUNT(*)
FROM rdb$relations r
WHERE
    COALESCE(r.rdb$system_flag, 0) = 0
    AND
    rdb$view_blr IS NULL
    AND
    rdb$relation_name = '{stringTypeMapping.GenerateSqlLiteral(TableName)}'";

It should be changed into:

                return $@"
SELECT COUNT(*)
FROM rdb$relations r
WHERE
    COALESCE(r.rdb$system_flag, 0) = 0
    AND
    rdb$view_blr IS NULL
    AND
    rdb$relation_name = {stringTypeMapping.GenerateSqlLiteral(TableName)}";

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