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

Embeded types confusing with order by #174

Closed
jt-helsinki opened this issue Jan 5, 2017 · 1 comment
Closed

Embeded types confusing with order by #174

jt-helsinki opened this issue Jan 5, 2017 · 1 comment

Comments

@jt-helsinki
Copy link

I have an object with an embedded object (why, I don't know... ;o)

@Table()
export class Organisation {

    @PrimaryGeneratedColumn()
    id: number;

    @Column("string", { length: "250" })
    name: string;

    @Embedded(type => Contact)
    primaryContact: Contact;

}

@EmbeddableTable()
export class Contact {

    @Column("string", { length: "50", nullable: true })
    name: string;

    @Column("string", { length: "50", nullable: true  })
    email: string;

}

Note that each object has a "name" property. Which gives Organisation.name and Organisation.primaryContactName columns in the Database.

I try to do a select on this object ordering by organisation.name.

this.ormRepository
            .createQueryBuilder("organisation")
            .andWhere("organisation.organisationType = :organisationType")
            .andWhere("organisation.federationId = :federationId")
            .orderBy("organisation.name")
            .setParameter("organisationType", organisationType)
            .setParameter("federationId", federationId)
            .getMany();

The SQL that is generated is:

SELECT 
organisation.id AS organisation_id, 
organisation.name AS organisation_name, 
...
organisation.primaryContactName AS organisation_primaryContactName 
...
FROM organisation organisation WHERE organisation.id = ? 
..
ORDER BY organisation.primaryContactName ASC -- PARAMETERS: [..,10]

The orderby column is conflicting.

Cheers

JT

@pleerock
Copy link
Member

released in 0.0.7-alpha.11

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