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]: Type error when using subquery in where #2395

Closed
livingforjesus opened this issue May 29, 2024 · 5 comments
Closed

[BUG]: Type error when using subquery in where #2395

livingforjesus opened this issue May 29, 2024 · 5 comments

Comments

@livingforjesus
Copy link
Contributor

What version of drizzle-orm are you using?

0.30.10

What version of drizzle-kit are you using?

0.21.1

Describe the Bug

I get the type error:
Argument of type 'Aliased' is not assignable to parameter of type 'Column<ColumnBaseConfig<ColumnDataType, string>, object, object>'.
Type 'Aliased' is missing the following properties from type 'Column<ColumnBaseConfig<ColumnDataType, string>, object, object>': table, name, primary, notNull, and 14 more.

whenever I'm creating this drizzle code:

const tagsSubquery = db
    .select({
      id: listings.id,
      tag: sql<string>`UNNEST(${listings.tags})`.as('tag')
    })
    .from(listings)
    .where(eq(listings.marketplaceIntegrationId, marketplaceIntegrationId))
    .as('tags');
  const [{ tags }] = await db
    .select({
      tags: sql<SearchTagsResponse>`ARRAY_AGG(DISTINCT tag)`
    })
    .from(tagsSubquery)
    .where(
      and(
        ilike(tagsSubquery.tag, `%${searchTerm}%`),
        notInArray(tagsSubquery.tag, excludeTags!).if(excludeTags?.length)
      )
    );

The type error is on ilike(tagsSubquery.tag, %${searchTerm}%),
image

The query works but the type error is annoying

Expected behavior

I expect no type error

Environment & setup

postgres db

@livingforjesus livingforjesus added the bug Something isn't working label May 29, 2024
@adiSuper94
Copy link

I am facing the same issue. I am migrating form js to ts this is blocking me.
I know I can do obj["key"]. But then what is the point of ts when I am dodging type checks?

Alt Text

@adiSuper94
Copy link

Id be glad to attempt fixing this issue if someone is willing to guide me through it.
@Angelelz

@Angelelz
Copy link
Collaborator

Angelelz commented Jun 24, 2024

Id be glad to attempt fixing this issue if someone is willing to guide me through it.
@Angelelz

I can't offer my help at this time. I haven't been able to help with drizzle development in several months. The first thing I would ask is what does the error say?
Edit: nevermind I just re-read the issue

@adiSuper94
Copy link

@Angelelz, cool. Thanks for the reply. I tagged you cuz I have just interacted with you on discord. But if you feel anyone else can help with this, please feel free to tag them instead.

@AndriiSherman
Copy link
Member

fixed in drizzle-orm@0.36.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants