From 363614dff59bd54e81062ea45baf4fb56efa83ab Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Fri, 7 Aug 2009 02:49:20 +0000 Subject: [PATCH] Zell may want to refute that this is a good idea, but if I try to order by a computed field in a computed record, Depot freaks out because it doesn't know what table the computed field comes from when it doesn't come from any table. So clearly this is what we want to achieve that functionality, but what I'm not 100% sure about is what ass biting we're opening ourselves up to here by not freaking out in this case. We may be taking a step backwards in terms of useful error reporting if someone does something stupid with computed fields. But we'll just have to see what those errors are when they crop up. If the database can't figure out what we're talking about with the unqualified field name, it too will freak out. --- .../samskivert/depot/impl/BuildVisitor.java | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/src/java/com/samskivert/depot/impl/BuildVisitor.java b/src/java/com/samskivert/depot/impl/BuildVisitor.java index 1c1a6b5..cba7ac4 100644 --- a/src/java/com/samskivert/depot/impl/BuildVisitor.java +++ b/src/java/com/samskivert/depot/impl/BuildVisitor.java @@ -690,19 +690,15 @@ public abstract class BuildVisitor implements ExpressionVisitor } } - // if we get this far we hopefully have a table to select from - if (tableClass != null) { - if (_defaultType != tableClass) { - appendTableAbbreviation(tableClass); - _builder.append("."); - } - appendIdentifier(fm.getColumnName()); - return; + // if we get this far we hopefully have a table to select from, if not we're probably doing + // something like an order by on a synthetic field "select count(distinct foo) as bar from + // ... order by bar", so we just skip the table qualifier + if (tableClass != null && _defaultType != tableClass) { + appendTableAbbreviation(tableClass); + _builder.append("."); } - // else owie - throw new IllegalArgumentException( - "Persistent field has no definition [class=" + type + ", field=" + field + "]"); + appendIdentifier(fm.getColumnName()); } // output one of potentially many fields in an index expression