Skip to content

Start using table schema in queries with Postgres#6

Merged
curranosaurus merged 8 commits intomasterfrom
curran/use-schema-in-postgresql-queries
Oct 3, 2024
Merged

Start using table schema in queries with Postgres#6
curranosaurus merged 8 commits intomasterfrom
curran/use-schema-in-postgresql-queries

Conversation

@curranosaurus
Copy link
Copy Markdown
Owner

@curranosaurus curranosaurus commented Oct 1, 2024

I tested this PR by hardcoding entitySchema = Just $ SchemaNameDB "foo", and it broke the Postgres test suite with the error message "schema foo not found". This means that the schema we specify is making it into the queries we dispatch.

, "AND kcu.table_schema=? "
, "AND kcu.column_name=? "
, "AND tc.constraint_name=?"
]
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This information_schema query change is a non-trivial change to the way Persistent and Postgres integrate. I think that my change is in the spirit of the original, but reviewers should verify for themselves that this makes sense.

@curranosaurus curranosaurus force-pushed the curran/use-schema-in-postgresql-queries branch from 6f6c886 to 4b37e1e Compare October 2, 2024 16:48
-- allow specifying the schema of the foreign
-- relation. We need to add the ability to parse
-- schema=foo directives inline for foreign keys
-- and insert those values here.
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This adds another .persistentmodels parser task.

I inferred that we need to make this change based on the block comment on UnboundForeignDef:

-- | Define an explicit foreign key reference.
--
-- @
-- User
--     name Text
--     email Text
--
--     Primary name email
--
-- Dog
--     ownerName Text
--     ownerEmail Text
--
--     Foreign User fk_dog_user ownerName ownerEmail
-- @
--
-- @since 2.13.0.0
data UnboundForeignDef

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hopefully resolved with #9

@curranosaurus curranosaurus changed the title Curran/use schema in postgresql queries Start using table schema in queries with Postgres Oct 2, 2024
@curranosaurus curranosaurus marked this pull request as ready for review October 2, 2024 16:55
…s-migrations

Use new entitySchema field for Postgres migrations
@curranosaurus curranosaurus merged commit 8fe5757 into master Oct 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants