Skip to content

ReadModelSqlGenerator Column Prefix and Suffix - Not Used in Select Query #1002

@VladislavRybnikov

Description

@VladislavRybnikov

Hi!

I am using PostgreSQL read models and discovered an issue with the column names.

STR

  1. I created all tables with double-quoted values for table and column names using FluentMigrator (this is the default FluentMigrator PostgreSQl configuration).
  2. I registered PostgreSql readModels using ConfigurePostgreSql and UsePostgreSqlReadModel
  3. I added [PostgreSqlReadModelIdentityColumn] attribute to ReadModel's property Id

AR
When working with read models I am receiving an error from PostgreSQL that column id does not exists

ER
Should work well with such configuration by default OR should be configured by registering custom ReadModelSqlGenerator:

internal sealed class CustomPostgresReadModelSqlGenerator : ReadModelSqlGenerator
{
    public CustomPostgresReadModelSqlGenerator()
        : base(new ReadModelSqlGeneratorConfiguration(
            tableQuotedIdentifierPrefix: "\"",
            tableQuotedIdentifierSuffix: "\"",
            columnQuotedIdentifierPrefix: "\"",
            columnQuotedIdentifierSuffix: "\""))
    {
    }
}

But even registration of this custom ReadModelSqlGenerator does not help, because probably there is a bug in ReadModelSqlGenerator.

sql = $"SELECT * FROM {tableName} WHERE {identityColumn} = @EventFlowReadModelId";
- on this line prefix and suffix - not used at all, so probably it is a bug, because they are used here -
sql = $"UPDATE {tableName} SET {updateColumns} WHERE {Configuration.ColumnQuotedIdentifierPrefix}{identityColumn}{Configuration.ColumnQuotedIdentifierSuffix} = @{identityColumn} {versionCheck}";
.

Also, there is a question, why columnQuotedIdentifierPrefix: "\"" and columnQuotedIdentifierSuffix: "\"" - not used by default for PostgreSql configuration?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions