Skip to content

persistent should support schema-qualified table names #93

@joeyadams

Description

@joeyadams

My particular problem involves PostgreSQL and schema-qualified table names:

CREATE TABLE acme.groups (
    id      SERIAL PRIMARY KEY,
    name    TEXT NOT NULL
);

CREATE TABLE acme.widgets (
    id      SERIAL PRIMARY KEY,
    "group" INT NOT NULL REFERENCES acme.groups(id),
    name    TEXT NOT NULL
);

However, this won't do what I want:

mkPersist sqlSettings [persist|
Widget sql=acme.widgets
    group   GroupId
    name    Text
    deriving Show
Group sql=acme.groups
    name    Text
    deriving Show
|]

because "acme.widgets" is quoted as a single identifier, which Postgres treats as a single identifier, rather than a schema-qualified name.

Because my database uses schema-qualified names for everything, it looks like I can't use persistent with it. This issue is related to pull request #82, where someone wanted a similar feature to access nested MongoDB objects, where the schema was already defined.

The easy fix would be to update each backend's escape function to not escape ., but this would be technically incorrect (in PostgreSQL, a quoted identifier may include "." in its name). The harder fix would be to support nested labels.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions