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

Wrong select in with big int #4227

Closed
alexhype17 opened this issue Apr 15, 2023 · 1 comment
Closed

Wrong select in with big int #4227

alexhype17 opened this issue Apr 15, 2023 · 1 comment

Comments

@alexhype17
Copy link

Describe the bug
Wrong select in with big int

Stack trace

error: select "item".*, "bids"."id" as "bids__id", "bids"."item_id" as "bids__item_id" from "item_entity" as "item" left join "bid_entity" as "bids" on "item"."id" = "bids"."item_id" where "item"."id" in 'select "item"."id" from (select "item"."id" from "item_entity" as "item" left join "bid_entity" as "bids" on "item"."id" = "bids"."item_id" group by "item"."id" limit 10) as "item"' - syntax error at or near "'select "item"."id" from (select "item"."id" from "item_entity" as "item" left join "bid_entity" as "bids" on "item"."id" = "bids"."item_id" group by "item"."id" limit 10) as "item"'"

      at Parser.parseErrorMessage (node_modules/pg-protocol/src/parser.ts:369:69)
      at Parser.handlePacket (node_modules/pg-protocol/src/parser.ts:188:21)
      at Parser.parse (node_modules/pg-protocol/src/parser.ts:103:30)
      at Socket.<anonymous> (node_modules/pg-protocol/src/index.ts:7:48)

To Reproduce

import {
  Entity,
  LoadStrategy,
  SimpleLogger, OneToMany, ManyToOne, Collection, PrimaryKey, BigIntType,
} from '@mikro-orm/core';
import { MikroORM } from '@mikro-orm/postgresql';

@Entity()
class BidEntity {
  @PrimaryKey({ type: BigIntType })
  id!: string;

  @ManyToOne('ItemEntity', {
    serializer: value => value.id,
    serializedName: 'itemId',
  })
  item: any;
}

@Entity()
class ItemEntity {
  @PrimaryKey({ type: BigIntType })
  id!: string;

  @OneToMany('BidEntity', 'item', {
    orphanRemoval: true,
    strategy: LoadStrategy.JOINED,
    mappedBy: 'item',
  })
  bids = new Collection<BidEntity>(this);
}

let orm: MikroORM;

beforeAll(async () => {
  orm = await MikroORM.init({
    dbName: ':memory:',
    entities: [BidEntity, ItemEntity],
    loggerFactory: options => new SimpleLogger(options),
  });
  await orm.schema.refreshDatabase();
});

afterAll(() => orm.close(true));

test('select big int', async () => {
  await orm.em
    .createQueryBuilder(ItemEntity, 'item')
    .select('*')
    .leftJoinAndSelect('item.bids', 'bids')
    .limit(10)
    .getResultAndCount();
});

Versions

Dependency Version
node 16.18.0
typescript 5.0.4
mikro-orm 5.6.16
your-driver postgresql
@B4nan
Copy link
Member

B4nan commented Apr 18, 2023

Fixed via b789031

@B4nan B4nan closed this as completed Apr 18, 2023
jsprw pushed a commit to jsprw/mikro-orm-full-text-operators that referenced this issue May 7, 2023
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

No branches or pull requests

2 participants