Skip to content

Instantly share code, notes, and snippets.

@d6y
Created June 25, 2018 10:23
Show Gist options
  • Save d6y/9b1ac0c04b2ad64c18e85a0fac5982b9 to your computer and use it in GitHub Desktop.
Save d6y/9b1ac0c04b2ad64c18e85a0fac5982b9 to your computer and use it in GitHub Desktop.
filterQuery.map(_.name).update("new")
-------- QUERY 2 (WRONG):
DEBUG slick.compiler.QueryCompiler - Source:
| Bind
| from s2: Filter s3
| from s3: TableExpansion
| table s4: Table a
| columns: TypeMapping
| 0: ProductNode
| 1: Path s4.id : Int'
| 2: Path s4.relatesTo : Option[Int']
| 3: Path s4.name : String'
| where: Apply Function exists
| 0: Filter s5
| from s5: TableExpansion
| table s4: Table a
| columns: TypeMapping
| 0: ProductNode
| 1: Path s4.id : Int'
| 2: Path s4.relatesTo : Option[Int']
| 3: Path s4.name : String'
| where: Apply Function =
| 0: Path s3.relatesTo : Option[Int']
| 1: Path s5.id : Int'
| select: Pure t6
| value: Path s2.name : String'
DEBUG slick.compiler.QueryCompiler - After phase assignUniqueSymbols:
| Bind
| from s7: Filter s8
| from s8: TableExpansion
| table s9: Table a
| columns: TypeMapping
| 0: ProductNode
| 1: Path s9.id : Int'
| 2: Path s9.relatesTo : Option[Int']
| 3: Path s9.name : String'
| where: Apply Function exists
| 0: Filter s11
| from s11: TableExpansion
| table s12: Table a
| columns: TypeMapping
| 0: ProductNode
| 1: Path s12.id : Int'
| 2: Path s12.relatesTo : Option[Int']
| 3: Path s12.name : String'
| where: Apply Function =
| 0: Path s8.relatesTo : Option[Int']
| 1: Path s11.id : Int'
| select: Pure t14
| value: Path s7.name : String'
DEBUG slick.compiler.QueryCompiler - After phase unrollTailBinds: (no change)
DEBUG slick.compiler.QueryCompiler - After phase inferTypes: (no change)
DEBUG slick.compiler.QueryCompiler - After phase expandTables:
| Bind : Vector[t14<String'>]
| from s7: Filter s8 : Vector[@t10<{id: Int', relatesTo: Option[Int'], name: String'}>]
| from s8: Table a : Vector[@t10<{id: Int', relatesTo: Option[Int'], name: String'}>]
| where: Apply Function exists : Boolean
| 0: Filter s11 : Vector[@t13<{id: Int', relatesTo: Option[Int'], name: String'}>]
| from s11: Table a : Vector[@t13<{id: Int', relatesTo: Option[Int'], name: String'}>]
| where: Apply Function = : SOption[Boolean]
| 0: Path s8.relatesTo : Option[Int']
| 1: Path s11.id : Int'
| select: Pure t14 : Vector[t14<String'>]
| value: Path s7.name : String'
DEBUG slick.compiler.QueryCompiler - After phase forceOuterBinds:
| Bind : Vector[t14<String'>]
| from s7: Filter s8 : Vector[@t10<{id: Int', relatesTo: Option[Int'], name: String'}>]
| from s8: Table a : Vector[@t10<{id: Int', relatesTo: Option[Int'], name: String'}>]
| where: Apply Function exists : Boolean
| 0: Bind : Vector[t16<@t13<{id: Int', relatesTo: Option[Int'], name: String'}>>]
| from s15: Filter s11 : Vector[@t13<{id: Int', relatesTo: Option[Int'], name: String'}>]
| from s11: Table a : Vector[@t13<{id: Int', relatesTo: Option[Int'], name: String'}>]
| where: Apply Function = : SOption[Boolean]
| 0: Path s8.relatesTo : Option[Int']
| 1: Path s11.id : Int'
| select: Pure t16 : Vector[t16<@t13<{id: Int', relatesTo: Option[Int'], name: String'}>>]
| value: Ref s15 : @t13<{id: Int', relatesTo: Option[Int'], name: String'}>
| select: Pure t14 : Vector[t14<String'>]
| value: Path s7.name : String'
DEBUG slick.compiler.QueryCompiler - After phase removeMappedTypes: (no change)
DEBUG slick.compiler.QueryCompiler - After phase expandSums: (no change)
DEBUG slick.compiler.QueryCompiler - After phase emulateOuterJoins: (no change)
DEBUG slick.compiler.QueryCompiler - After phase expandRecords:
| Bind : Vector[t14<String'>]
| from s7: Filter s8 : Vector[@t10<{id: Int', relatesTo: Option[Int'], name: String'}>]
| from s8: Table a : Vector[@t10<{id: Int', relatesTo: Option[Int'], name: String'}>]
| where: Apply Function exists : Boolean
| 0: Bind : Vector[t16<{id: Int', relatesTo: Option[Int'], name: String'}>]
| from s15: Filter s11 : Vector[@t13<{id: Int', relatesTo: Option[Int'], name: String'}>]
| from s11: Table a : Vector[@t13<{id: Int', relatesTo: Option[Int'], name: String'}>]
| where: Apply Function = : SOption[Boolean]
| 0: Path s8.relatesTo : Option[Int']
| 1: Path s11.id : Int'
| select: Pure t16 : Vector[t16<{id: Int', relatesTo: Option[Int'], name: String'}>]
| value: StructNode : {id: Int', relatesTo: Option[Int'], name: String'}
| id: Path s15.id : Int'
| relatesTo: Path s15.relatesTo : Option[Int']
| name: Path s15.name : String'
| select: Pure t14 : Vector[t14<String'>]
| value: Path s7.name : String'
DEBUG slick.compiler.QueryCompiler - After phase flattenProjections:
| Bind : Vector[t14<{s17: String'}>]
| from s7: Filter s8 : Vector[@t10<{id: Int', relatesTo: Option[Int'], name: String'}>]
| from s8: Table a : Vector[@t10<{id: Int', relatesTo: Option[Int'], name: String'}>]
| where: Apply Function exists : Boolean
| 0: Bind : Vector[t16<{s18: Int', s19: Option[Int'], s20: String'}>]
| from s15: Filter s11 : Vector[@t13<{id: Int', relatesTo: Option[Int'], name: String'}>]
| from s11: Table a : Vector[@t13<{id: Int', relatesTo: Option[Int'], name: String'}>]
| where: Apply Function = : SOption[Boolean]
| 0: Path s8.relatesTo : Option[Int']
| 1: Path s11.id : Int'
| select: Pure t16 : Vector[t16<{s18: Int', s19: Option[Int'], s20: String'}>]
| value: StructNode : {s18: Int', s19: Option[Int'], s20: String'}
| s18: Path s15.id : Int'
| s19: Path s15.relatesTo : Option[Int']
| s20: Path s15.name : String'
| select: Pure t14 : Vector[t14<{s17: String'}>]
| value: StructNode : {s17: String'}
| s17: Path s7.name : String'
DEBUG slick.compiler.QueryCompiler - After phase rewriteJoins: (no change)
DEBUG slick.compiler.QueryCompiler - After phase verifySymbols: (no change)
DEBUG slick.compiler.QueryCompiler - After phase relabelUnions: (no change)
DEBUG slick.compiler.QueryCompiler - After phase createAggregates: (no change)
DEBUG slick.compiler.QueryCompiler - After phase resolveZipJoins: (no change)
DEBUG slick.compiler.QueryCompiler - After phase pruneProjections: (no change)
DEBUG slick.compiler.QueryCompiler - After phase rewriteDistinct: (no change)
DEBUG slick.compiler.QueryCompiler - After phase createResultSetMapping:
| ResultSetMapping : Vector[String']
| from s21: Bind : Vector[t14<{s17: String'}>]
| from s7: Filter s8 : Vector[@t10<{id: Int', relatesTo: Option[Int'], name: String'}>]
| from s8: Table a : Vector[@t10<{id: Int', relatesTo: Option[Int'], name: String'}>]
| where: Apply Function exists : Boolean
| 0: Bind : Vector[t16<{s18: Int', s19: Option[Int'], s20: String'}>]
| from s15: Filter s11 : Vector[@t13<{id: Int', relatesTo: Option[Int'], name: String'}>]
| from s11: Table a : Vector[@t13<{id: Int', relatesTo: Option[Int'], name: String'}>]
| where: Apply Function = : SOption[Boolean]
| 0: Path s8.relatesTo : Option[Int']
| 1: Path s11.id : Int'
| select: Pure t16 : Vector[t16<{s18: Int', s19: Option[Int'], s20: String'}>]
| value: StructNode : {s18: Int', s19: Option[Int'], s20: String'}
| s18: Path s15.id : Int'
| s19: Path s15.relatesTo : Option[Int']
| s20: Path s15.name : String'
| select: Pure t14 : Vector[t14<{s17: String'}>]
| value: StructNode : {s17: String'}
| s17: Path s7.name : String'
| map: Path s21.s17 : String'
DEBUG slick.compiler.QueryCompiler - After phase hoistClientOps:
| ResultSetMapping : Vector[String']
| from s21: Bind : Vector[t22<{s23: String'}>]
| from s7: Filter s8 : Vector[@t10<{id: Int', relatesTo: Option[Int'], name: String'}>]
| from s8: Table a : Vector[@t10<{id: Int', relatesTo: Option[Int'], name: String'}>]
| where: Apply Function exists : Boolean
| 0: Bind : Vector[t16<{s18: Int', s19: Option[Int'], s20: String'}>]
| from s15: Filter s11 : Vector[@t13<{id: Int', relatesTo: Option[Int'], name: String'}>]
| from s11: Table a : Vector[@t13<{id: Int', relatesTo: Option[Int'], name: String'}>]
| where: Apply Function = : SOption[Boolean]
| 0: Path s8.relatesTo : Option[Int']
| 1: Path s11.id : Int'
| select: Pure t16 : Vector[t16<{s18: Int', s19: Option[Int'], s20: String'}>]
| value: StructNode : {s18: Int', s19: Option[Int'], s20: String'}
| s18: Path s15.id : Int'
| s19: Path s15.relatesTo : Option[Int']
| s20: Path s15.name : String'
| select: Pure t22 : Vector[t22<{s23: String'}>]
| value: StructNode : {s23: String'}
| s23: Path s7.name : String'
| map: Path s21.s23 : String'
DEBUG slick.compiler.QueryCompiler - After phase reorderOperations: (no change)
DEBUG slick.compiler.QueryCompiler - After phase mergeToComprehensions:
| ResultSetMapping : Vector[String']
| from s21: Comprehension s24, Some(Apply Function exists), None, ConstArray(), None, None, None, None, false : Vector[t22<{s23: String'}>]
| from s24: Table a : Vector[@t10<{id: Int', relatesTo: Option[Int'], name: String'}>]
| select: Pure t22 : Vector[t22<{s23: String'}>]
| value: StructNode : {s23: String'}
| s23: Path s24.name : String'
| where: Apply Function exists : Boolean
| 0: Comprehension s25, Some(Apply Function =), None, ConstArray(), None, None, None, None, false : Vector[t16<{s18: Int', s19: Option[Int'], s20: String'}>]
| from s25: Table a : Vector[@t13<{id: Int', relatesTo: Option[Int'], name: String'}>]
| select: Pure t16 : Vector[t16<{s18: Int', s19: Option[Int'], s20: String'}>]
| value: StructNode : {s18: Int', s19: Option[Int'], s20: String'}
| s18: Path s25.id : Int'
| s19: Path s25.relatesTo : Option[Int']
| s20: Path s25.name : String'
| where: Apply Function = : SOption[Boolean]
| 0: Path s24.relatesTo : Option[Int']
| 1: Path s25.id : Int'
| map: Path s21.s23 : String'
DEBUG slick.compiler.QueryCompiler - After phase optimizeScalar: (no change)
DEBUG slick.compiler.QueryCompiler - After phase removeFieldNames:
| ResultSetMapping : Vector[String']
| from s21: Comprehension s24, Some(Apply Function exists), None, ConstArray(), None, None, None, None, false : Vector[t22<(String')>]
| from s24: Table a : Vector[@t10<{id: Int', relatesTo: Option[Int'], name: String'}>]
| select: Pure t22 : Vector[t22<(String')>]
| value: ProductNode : (String')
| 1: Path s24.name : String'
| where: Apply Function exists : Boolean
| 0: Comprehension s25, Some(Apply Function =), None, ConstArray(), None, None, None, None, false : Vector[t16<(Int', Option[Int'], String')>]
| from s25: Table a : Vector[@t13<{id: Int', relatesTo: Option[Int'], name: String'}>]
| select: Pure t16 : Vector[t16<(Int', Option[Int'], String')>]
| value: ProductNode : (Int', Option[Int'], String')
| 1: Path s25.id : Int'
| 2: Path s25.relatesTo : Option[Int']
| 3: Path s25.name : String'
| where: Apply Function = : SOption[Boolean]
| 0: Path s24.relatesTo : Option[Int']
| 1: Path s25.id : Int'
| map: Path s21._1 : String'
DEBUG slick.compiler.QueryCompiler - After phase codeGen:
| ResultSetMapping : Vector[String']
| from s21: CompiledStatement "update "a" set "name" = ? where exists(select "id", "relatesTo", "name" from "a" where "a"."relatesTo" = "id")" : Vector[t22<(String')>]
| map: CompiledMapping : String'
| converter: SpecializedJdbcResultConverter$$anon$1 idx=1, name=<computed> : String'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment