You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#[test]
fn campaign_access_controlled_by() {
let actual = campaign::Entity::find()
.select_only()
.column(campaign::Column::Id)
.join(JoinType::InnerJoin, SubjectToAccessControl::Campaign.def())
.filter(access_control::Column::Id.eq(Uuid::default()))
.build(DbBackend::Postgres)
.to_string();
let expected = r#"
SELECT
"campaign"."id"
FROM "campaign" INNER JOIN "access_control"
ON "campaign"."id" = "access_control"."subject_entity_id" AND
"access_control"."subject_entity_type" = 'campaign'
WHERE
"access_control"."id" = '00000000-0000-0000-0000-000000000000'
"#;
let normalized_expected = normalize_whitespace(expected);
let normalized_actual = normalize_whitespace(&actual);
assert_eq!(normalized_expected, normalized_actual);
}
But fails for
#[test]
fn rev_campaign_access_controlled_by() {
let actual = access_control::Entity::find()
.select_only()
.column(access_control::Column::Id)
.join(JoinType::InnerJoin, SubjectToAccessControl::Campaign.def().rev())
.filter(campaign::Column::Id.eq(Uuid::default()))
.build(DbBackend::Postgres)
.to_string();
let expected = r#"
SELECT
"access_control"."id"
FROM "access_control" INNER JOIN "campaign"
ON "access_control"."subject_entity_id" = "campaign"."id" AND
"access_control"."subject_entity_type" = 'campaign'
WHERE
"campaign"."id" = '00000000-0000-0000-0000-000000000000'
"#;
let normalized_expected = normalize_whitespace(expected);
let normalized_actual = normalize_whitespace(&actual);
assert_eq!(normalized_expected, normalized_actual);
}
Because the sql produced is
SELECT
"access_control"."id"
FROM "access_control" INNER JOIN "campaign"
ON "access_control"."subject_entity_id" = "campaign"."id" AND
"campaign"."subject_entity_type" = 'campaign'
WHERE
"campaign"."id" = '00000000-0000-0000-0000-000000000000'
and campaign does not have a 'subject_entity_type', access_control does.
From my perspective the trouble is that rev is implemented as:
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I have
which works fine for:
But fails for
Because the sql produced is
and campaign does not have a 'subject_entity_type', access_control does.
From my perspective the trouble is that rev is implemented as:
Where I would expect it to be something more like:
But, a lot of people are using it as is. So, how to we write our on_condition so that a rev does not clobber it?
Beta Was this translation helpful? Give feedback.
All reactions