-
Notifications
You must be signed in to change notification settings - Fork 211
Add the Ability to Specify an Alias in a Table Object #426
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
Conversation
Hi, I got this in my project but looks like it's not working for Here is an example amlObjectMapper.selectDistinct(select -> select
.join(amlAttachment, "attachment", on(amlObject.objectid, equalTo(amlAttachment.attachmentid)), and(amlObject.objecttypeid, equalTo(amlAttachment.attachmenttypeid)))
.where(amlObject.objecttypeid, isEqualTo(AmlObjectType.ATTACHMENT.getValue()))
.and(exists(select(of("1"))
.from(taxonomyControlAttachment, "tca")
.where(taxonomyControlAttachment.attachmentcontrolid, isEqualTo(taxonomyControlIdVersion))
.and(taxonomyControlAttachment.attachmentid, isEqualTo(amlAttachment.attachmentid))
.and(taxonomyControlAttachment.attachmenttypeid, isEqualTo(amlAttachment.attachmenttypeid))
.applyWhere(limitToTypes != null && limitToTypes.length > 0
? where -> where.and(amlAttachment.attachmenttype, isIn(limitToTypes))
: x -> {
})
)) Resulting query select distinct AML_Objects.ObjectId,
AML_Objects.ObjectTypeId,
AML_Objects.ObjectUpdatedBy,
AML_Objects.ObjectCreatedBy,
AML_Objects.ObjectUpdated,
AML_Objects.ObjectCreated
from AML_Objects
join AML_Attachments attachment on AML_Objects.ObjectId = attachment.AttachmentId and
AML_Objects.ObjectTypeId = attachment.AttachmentTypeId
where AML_Objects.ObjectTypeId = ?
and exists(select 1
from TAXO_TaxonomyControlAttachments tca
where tca.AttachmentControlId = ?
and tca.AttachmentId = AttachmentId
and tca.AttachmentTypeId = AttachmentTypeId) Expected query (fragment) and tca.AttachmentId = attachment.AttachmentId
and tca.AttachmentTypeId = attachment.AttachmentTypeId) This is likely because the referenced object I can confirm, however, this fixes the self-join alias problem. For the join queries, of course. |
Please note this is not critical to our team as we could change the query in order to make it work. For now, we are not stuck |
The aliases specified this way will not carry into to exists queries (or union queries either). You have a couple of options:
|
@djechelon I've created a new issue for aliases in exists queries - I should be able to solve this. You can track progress here: #437 |
This PR adds a new meta-model object
AliasableSqlTable
that can contain an alias to be used when a select statement is rendered.Resolves #413