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

Incorrect abstract SQL generated for M-M link fields #18

Open
pimterry opened this issue May 29, 2018 · 0 comments
Open

Incorrect abstract SQL generated for M-M link fields #18

pimterry opened this issue May 29, 2018 · 0 comments
Assignees

Comments

@pimterry
Copy link
Contributor

Given the rule:

It is necessary that each plan that includes a plan feature that provides a feature1, includes at most one plan feature that provides the feature1

(using the model from https://github.com/resin-io/resin-api/pull/1020)

we end up with the following SQL:

SELECT NOT EXISTS (
	SELECT 1
	FROM "plan" AS "plan.0",
			"plan feature" AS "plan feature.1",
			"feature" AS "feature.2",
			"plan-includes-plan feature" AS "plan.0-includes-plan feature.1"
	WHERE "plan feature.1"."provides-feature" = "feature.2"."id"
	AND "plan.0-includes-plan feature.1"."plan" = "plan.0"."id"
	AND "plan.0-includes-plan feature.1"."plan feature" = "plan feature.1"."id"
	AND (
			SELECT COUNT(*)
			FROM "plan feature" AS "plan feature.3",
					"plan-includes-plan feature" AS "plan.0-includes-plan feature.3"
			WHERE "plan feature.3"."provides-feature" = "feature.2"."id"
			AND "plan.0-includes-plan feature.3"."plan" = "plan.0"."id"
			AND "plan.0-includes-plan feature.3"."plan feature" = "plan feature.3"."id"
	) >= 2
 ) AS "result";

This doesn't work. plan-includes-plan feature has two field, plan and includes-plan feature, but this references a non-existent plan feature field.

This is a bug at the LF level, which is making some assumptions about FK field names that are no longer true.

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

1 participant