Skip to content

Confusing silent failure when schemaName case doesn't match actual (quoted) schema — respectCase requirement not surfaced anywhere except README #91

Description

@mahdiyar021

Describe the bug

When schemaName is passed to WriteTo.PostgreSQL(...) without setting respectCase: true,
the sink emits unquoted identifiers (e.g. CREATE TABLE IF NOT EXISTS Log.Events), which
Postgres case-folds to lowercase (log.events). If the schema actually exists with
preserved case (e.g. created via CREATE SCHEMA "Log" in an EF Core migration), the sink
fails with:

ERROR: schema "log" does not exist at character 28
STATEMENT: CREATE TABLE IF NOT EXISTS Log.Events (...)

This error repeats on every log write attempt and is easy to miss since Serilog sinks fail
silently/internally by default (self-log only). There's no indication that the fix is
respectCase: true unless you already know to check the README.

To Reproduce

  1. Create a Postgres schema with mixed case, e.g. CREATE SCHEMA "Log";
  2. Configure the sink:
   .WriteTo.PostgreSQL(connectionString, "Events", schemaName: "Log", needAutoCreateTable: true)
  1. Observe repeated Postgres errors: schema "log" does not exist

Expected behavior

Either:

  • respectCase should default to true (safer default — quoting is a no-op when case
    already matches lowercase), or
  • The sink should detect a schema-not-found error caused by case folding and emit a clear
    self-log warning suggesting respectCase: true, or
  • The docs/XML summary on schemaName parameter should explicitly warn about this instead
    of only being covered in the README's general "mixed case" note.

Workaround

Setting respectCase: true explicitly resolves it, as documented in the README.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions