Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]: Postgres Schema and Table name not properly escaped #2400

Closed
deanvanniekerk opened this issue May 30, 2024 · 1 comment
Closed

[BUG]: Postgres Schema and Table name not properly escaped #2400

deanvanniekerk opened this issue May 30, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@deanvanniekerk
Copy link

deanvanniekerk commented May 30, 2024

What version of drizzle-orm are you using?

0.30.10

What version of drizzle-kit are you using?

0.21.4

Describe the Bug

Given a postgres schema and table name:

export const transactions = pgSchema("transactions");

export const TokenSwapInTransactions = transactions.table(
  "TokenSwap",
  {
    swapId: text("swapId").primaryKey().notNull(),
    transactionHash: text("transactionHash").notNull()
  }
);

when performing this query

const lastTokenSwapQuery = db.query.TokenSwapInTransactions.findFirst({
    orderBy: (tokenSwap, { desc }) => [desc(tokenSwap.logIndex)],
});

causes the following run time error

PostgresError: relation "transactions.TokenSwap" does not exist

the issue is that the schema and table name are not being correctly escaped

Expected behavior

Schema and Table names should be escaped in the format "{schema}"."{table}".

so in the example above "transactions.TokenSwap" should be "transactions"."TokenSwap"

Environment & setup

nodejs v20

@deanvanniekerk deanvanniekerk added the bug Something isn't working label May 30, 2024
@deanvanniekerk
Copy link
Author

im so DUMB, I was pointing to the wrong db. This is not a bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant