apache / apache/grails-core

Add conditionals to joinTable column mapping

Open
#14,621 1 comment 0 reactions 0 assignees View on GitHub
relates-to: grails-data-hibernate5 type: improvement
Dominant language
Groovy
Stars
2.9k
Forks
975
Avg merge
1d 22h
Merged PRs (30d)
92

Description

Thanks for the great work! Just a hope for a future enhancement. But basically, it would be nice to be able to add conditions to a joinTable, based on instance values or hard coded values on column names. I've used it in rails several times, and my projects where I use Grails mostly, the ability is sorely missed. See example below:

```groovy

class Employee {
static hasMany = [projects: Project]

static mapping = {
projects joinTable: [name: 'EMP_PROJ',
column: 'PROJECT_ID',
key: 'EMPLOYEE_ID', where: {->
[type_column: this.some_discriminator_column_of_this_instance]
}
}
}
```

Contributor guide

Open the contributing guide

Research direction

Start by tracing Grails' joinTable column-mapping behavior; the issue provides no file or test names. Compare the requested instance-based and hard-coded conditions with existing mapping behavior, and consider the work complete when joinTable supports the example condition reliably with appropriate tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
groovy
Domain
backend, databases
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.