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

Improve relation filter query #2771

Merged
merged 17 commits into from Jul 26, 2018

Conversation

Projects
None yet
2 participants
@do4gr
Copy link
Member

commented Jul 13, 2018

  • avoids correlated subqueries when using relation filters
  • also fixes a bug when logical filters like AND, OR, NOT were passing in an empty array

@do4gr do4gr changed the base branch from master to alpha Jul 13, 2018

@prisma prisma deleted a comment from codacy-bot Jul 15, 2018

do4gr added some commits Jul 16, 2018

Merge branch 'alpha' into ImproveRelationFilterQuery
# Conflicts:
#	server/connectors/api-connector-jdbc/src/main/scala/com/prisma/api/connector/jdbc/database/NodeManyQueries.scala

@prisma prisma deleted a comment from codacy-bot Jul 19, 2018

@prisma prisma deleted a comment from codacy-bot Jul 19, 2018

@prisma prisma deleted a comment from codacy-bot Jul 19, 2018

@prisma prisma deleted a comment from codacy-bot Jul 20, 2018

@prisma prisma deleted a comment from codacy-bot Jul 20, 2018

@prisma prisma deleted a comment from codacy-bot Jul 20, 2018

@prisma prisma deleted a comment from codacy-bot Jul 20, 2018

@prisma prisma deleted a comment from codacy-bot Jul 20, 2018

@prisma prisma deleted a comment from codacy-bot Jul 20, 2018

@prisma prisma deleted a comment from codacy-bot Jul 20, 2018

@prisma prisma deleted a comment from codacy-bot Jul 20, 2018

@prisma prisma deleted a comment from codacy-bot Jul 20, 2018

@prisma prisma deleted a comment from codacy-bot Jul 20, 2018

@prisma prisma deleted a comment from codacy-bot Jul 20, 2018

@do4gr do4gr changed the title [WIP] Improve relation filter query Improve relation filter query Jul 20, 2018

@prisma prisma deleted a comment from codacy-bot Jul 20, 2018

@prisma prisma deleted a comment from codacy-bot Jul 20, 2018

@prisma prisma deleted a comment from codacy-bot Jul 20, 2018

@prisma prisma deleted a comment from codacy-bot Jul 20, 2018

case class PreComputedSubscriptionFilter(boolean: Boolean) extends Filter
case class NodeSubscriptionFilter() extends Filter
case class TrueFilter() extends Filter
case class FalseFilter() extends Filter

This comment has been minimized.

Copy link
@mavilein

mavilein Jul 26, 2018

Member

Those 3 filters can all be replaced with singleton objects as they do not have any parameters.

This comment has been minimized.

Copy link
@do4gr

do4gr Jul 26, 2018

Author Member

done

// importFile("nodes02.json")
// importFile("relations01.json")
// importFile("relations02.json")
// importFile("lists01.json")

This comment has been minimized.

Copy link
@mavilein

mavilein Jul 26, 2018

Member

Was this commenting intended?

This comment has been minimized.

Copy link
@do4gr

do4gr Jul 26, 2018

Author Member

This is an ignored test that is only used to quickly have data for testing while developing.

// artists(where:{albums_some:{tracks_some:{condition}}})
// albums(where: {Tracks_some:{ MediaType:{Name_starts_with:""}, Genre:{Name_starts_with:""}}})
// this will be an andFilter around the two nested ones and will not be skipped at the moment
// implicit AND like above as well as explicit AND, OR, NOT can be improve

This comment has been minimized.

Copy link
@mavilein

mavilein Jul 26, 2018

Member

the last sentence in the comment does not make sense.

This comment has been minimized.

Copy link
@do4gr

do4gr Jul 26, 2018

Author Member

made the comment more clear


relationFilter.condition match {
case AtLeastOneRelatedNode => modelIdColumn(alias, relationField.model).in(select.where(buildConditionForFilter(x, newAlias, relField)))
case EveryRelatedNode => modelIdColumn(alias, relationField.model).notIn(select.where(buildConditionForFilter(x, newAlias, relField, true)))

This comment has been minimized.

Copy link
@mavilein

mavilein Jul 26, 2018

Member

Let's always name boolean parameters.

}

override def beforeEach() = {
super.beforeEach()

This comment has been minimized.

Copy link
@mavilein

mavilein Jul 26, 2018

Member

Since you are only querying data, this could also go into beforeAll, right?

This comment has been minimized.

Copy link
@do4gr

do4gr Jul 26, 2018

Author Member

done

@prisma prisma deleted a comment from codacy-bot Jul 26, 2018

@prisma prisma deleted a comment from codacy-bot Jul 26, 2018

@do4gr do4gr merged commit f891fd4 into alpha Jul 26, 2018

@prisma prisma deleted a comment from codacy-bot Jul 26, 2018

@prisma prisma deleted a comment from codacy-bot Jul 26, 2018

@do4gr do4gr deleted the ImproveRelationFilterQuery branch Oct 22, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.