-
-
Notifications
You must be signed in to change notification settings - Fork 496
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
Unable to use nested properties in SELECT clause #3365
Comments
The same thing when using @Entity()
export class User {
@PrimaryKey()
id!: number;
@Property({ unique: true, length: 255 })
email!: string
@Property({ length: 255 })
fullName!: string
@Embedded(() => Address)
address: Address;
}
@Embeddable()
export class Address {
@Property()
city: string;
} const records = [{ email: 'test@test.test', fullName: 'John Smith', address: { city: 'Los Angeles' } }]
const query = this.em
.qb(User)
.insert(records)
.onConflict(['email'])
.merge(['fullName', 'address.city'])
.getQuery() Expected: insert into "users" ("email", "full_name", "address_city") values ($1, $2, $3) on conflict ("email") do update set "full_name" = excluded."full_name", "address_city" = excluded."address_city" returning "id"; Actual: insert into "users" ("email", "full_name", "address_city") values ($1, $2, $3) on conflict ("email") do update set "full_name" = excluded."full_name", "city" = excluded."city" returning "id"; |
I suppose you expect that |
Ok, this was harder than expected. |
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Description
When trying to use nested properties in a
QueryBuilder.select()
to retrieve a single or all embedded fields at once,QueryBuilder
throws an error:Stack trace
To Reproduce
Steps to reproduce the behavior:
Address
as follows:QueryBuilder
to retrieve address properties:or
or
Workaround
You still can receive a raw result using column names instead of fields as follows:
Actual behavior
QueryBuilder
throws an error trying to generate a SQL query.Expected behavior
QueryBuilder
is able to generate an expected SQL query in accordance with the naming strategy:select "u0"."address_city" from "user" as "u0"
Additional context
There is repro-repo here: https://github.com/derevnjuk/mikro-orm-3365
Versions
The text was updated successfully, but these errors were encountered: