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

Outer joins not recognized as nullable types #551

Open
FrankHeijden opened this issue Nov 23, 2023 · 0 comments
Open

Outer joins not recognized as nullable types #551

FrankHeijden opened this issue Nov 23, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@FrankHeijden
Copy link

Describe the bug
It seems from a previous issue that outer joins should be recognized as nullable, but in ^2.3.0 I cannot seem to replicate this behaviour.

Test case
tables.sql:

-- CreateTable
CREATE TABLE "A" (
    "id" SERIAL NOT NULL,
    "aStr" TEXT NOT NULL,

    CONSTRAINT "A_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "B" (
    "aId" INTEGER NOT NULL,
    "bStr" TEXT NOT NULL,

    CONSTRAINT "B_pkey" PRIMARY KEY ("aId")
);

-- AddForeignKey
ALTER TABLE "B" ADD CONSTRAINT "B_aId_fkey" FOREIGN KEY ("aId") REFERENCES "A"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

test.sql:

/* @name get */
SELECT a.*, b."bStr" FROM "A" a
LEFT JOIN public."B" b on a.id = b."aId";

The generated type for this query is:

/** 'Get' return type */
export interface IGetResult {
  aStr: string;
  bStr: string;
  id: number;
}

But I'd expect the following:

/** 'Get' return type */
export interface IGetResult {
  aStr: string;
  bStr: string | null;
  id: number;
}
@FrankHeijden FrankHeijden added the bug Something isn't working label Nov 23, 2023
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