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
SELECT aliases being referenced in WHERE statement clause Postgres #3669
Comments
FYI you can also use Also I would appreciate complete reproduction, there is a lot of ambiguity in provided entity definition. I don't want to know how your entities are set up or about your various base entity classes, I want simplicity but completeness. Lastly, I don't understand what you expect from having a 1:1 primary key as part of a composite key - by definition, it will be always unique on its own. edit: I just verified the very same problem surfaces without wrapping the query in |
@B4nan I ended up just removing the composite and making it a unique index and everything works fine now. Did you still want a repro? |
Already got one: import { Entity, ManyToOne, MikroORM, OneToOne, PrimaryKey, Property } from '@mikro-orm/core';
import type { SqliteDriver } from '@mikro-orm/sqlite';
@Entity()
class Vendor {
@PrimaryKey()
id!: number;
@Property()
prop!: string;
}
@Entity()
class TechnicianManager {
@ManyToOne({ entity: () => Vendor, primary: true })
vendor!: Vendor;
@OneToOne({ entity: () => User, primary: true })
user!: any;
}
@Entity()
class User {
@PrimaryKey()
id!: number;
@OneToOne(() => TechnicianManager, technician_manager => technician_manager.user)
technician_manager!: TechnicianManager;
}
describe('GH issue 3669', () => {
let orm: MikroORM<SqliteDriver>;
beforeAll(async () => {
orm = await MikroORM.init({
entities: [TechnicianManager],
dbName: ':memory:',
type: 'sqlite',
});
await orm.schema.createSchema();
});
afterAll(() => orm.close(true));
test('$not operator on 1:1 inverse side', async () => {
await expect(orm.em.find(User, { $not: { technician_manager: null } })).resolves.toEqual([]);
});
test('$ne operator on 1:1 inverse side', async () => {
await expect(orm.em.find(User, { technician_manager: { $ne: null } })).resolves.toEqual([]);
});
}); (generally, if I tag something as |
Describe the bug
Mikro seems to be using SELECT aliases in WHERE clause.
e.g.
Stack trace
To Reproduce
Steps to reproduce the behavior:
User Entity
TechnicianManager Entity
Where object
Versions
The text was updated successfully, but these errors were encountered: