As a note to myself, pasting long pieces of a convo with Steve Ebersole:
(03:27:56 PM) sebersole: some.joined.path.separated.by.dots (03:28:01 PM) sebersole: thats a implcit join (03:28:17 PM) sebersole: as opposed to the explicit form (03:28:31 PM) sebersole: from ... join ... join ... (03:29:05 PM) sebersole: this is where the parser is not very smart (03:29:13 PM) sebersole: the new parser is much better at this (03:29:40 PM) sebersole: really the rule is that it is ok to reuse non-leaf parts of implicit join paths always (03:30:04 PM) sebersole: for leaf parts it depends on a few things (03:30:20 PM) sebersole: the old parser does not understand all that (03:30:59 PM) sebersole: it does not understand that it has seen part of prod.supplier.supplierName before (03:31:57 PM) sebersole: in general it just elects to be safe when it does not know (04:09:11 PM) sebersole: select prod.supplier from Products prod order by prod.supplier.supplierName (04:09:17 PM) sebersole: so thats your query (04:09:37 PM) sebersole: but imagine... (04:11:01 PM) sebersole: well first let me back up... (04:11:17 PM) sebersole: the concern is filtering results that should not be filtered (04:12:41 PM) sebersole: its hard to make up these models on the fly to explain by way of an example (04:13:26 PM) sebersole: product -> supplier -> industry lets say (04:15:06 PM) sebersole: so first look at: (04:16:25 PM) sebersole: ... from Product p where p.supplier.industry.code = 'R&D' or p.supplier.hq.city = 'Austin' (04:17:23 PM) sebersole: so the issue is that inner joins have a semantic of removing missing correlations (04:18:03 PM) sebersole: here, if a product's supplier does not have a hq-address or does not have an industry... should they still be returned? (04:18:31 PM) sebersole: say for example, a product from the supplier Acme that has no industry, but is in Austin (04:18:39 PM) sebersole: should they get returned? (04:19:36 PM) sebersole: as far as the alias part... (04:19:42 PM) sebersole: there is another forms here.. (04:20:48 PM) sebersole: from Product p join p.supplier.industry i join p.supplier.hq h where i.code = 'R&D' or h.city = 'Austin' (04:21:17 PM) sebersole: but really where the alias part in my above commments come into play is in cases like: (04:22:32 PM) sebersole: select p.supplier.supplierName from Product p join p.supplier.industry i1 join p.supplier.industry i2 ... (04:23:19 PM) sebersole: its complicated, but the idea is that the 'p.supplier' join is probably safe to reuse (04:23:42 PM) sebersole: any dereference to 'p.supplier.industry; is not (04:23:51 PM) sebersole: any dereference to 'p.supplier.industry' is likely not (04:24:11 PM) sebersole: and even if it were safe... which woould you use? (04:24:27 PM) sebersole: so "safe" is releative to the path (04:24:44 PM) sebersole: aka, these aliases implicit joins are named (04:24:52 PM) sebersole: wow (04:24:56 PM) sebersole: aka, these aliased implicit joins are named (04:25:18 PM) sebersole: and so should not be reused (04:25:22 PM) sebersole: thats the safest (04:25:59 PM) sebersole: actually the new parser looks at each "path part" separate and decides (04:26:21 PM) sebersole: starting a new Join branch whenever it deems it needs to (04:26:27 PM) sebersole: so part could be reused (04:26:38 PM) sebersole: i think the current parser is not that smart (04:26:43 PM) sebersole: i think its all/none to it (04:27:12 PM) sebersole: aka, either the full p.supplier.industry path (04:27:28 PM) sebersole: aka, either the full p.supplier.industry path can be reused, or none of it (no part of it) can
|