Let me start off by saying I have been working on making the Peer system
handle OR where clauses.  And I have added the ability to alias tables
as well.

Now the proposal.  There is some code in BasePeer that attempts to
determine whether it should add a join to the where clause.  Here is the
condition

                // If criteriaColumn is not in the select list, but
                // its table contains a foreign key and its relatedKey
                // is in the select list, assume we want a simple
                // join.
                if ( !selectClause.contains(key) )
                {
                    // What if the criteria column is in the select
                    // list and the select list contains a column from
                    // a table which has another column associated a
                    // column in criteria column's table
                    ColumnMap[] possibleForeignKeys =
dbMap.getTable(table).getColumns();
                    for (int i=0; i<possibleForeignKeys.length; i++)
                    {
                        if ( possibleForeignKeys[i].isForeignKey()
                            &&
selectClause.contains(possibleForeignKeys[i].getRelatedName() ))
                        {
                            ignorCase = criteria.isIgnoreCase()  &&
                                (possibleForeignKeys[i].getType()
instanceof String);
                            whereClause.add(
SqlExpression.buildInnerJoin(
                               
possibleForeignKeys[i].getFullyQualifiedName(),
                                possibleForeignKeys[i].getRelatedName(),
                                ignorCase,
                                db));
                        }
                    }
                }

Is anyone depending on this code?  I would like to remove it.  

1.  It needs to be fixed to handle tables with a self reference foreign
key.
2.  I have to alter it to work with the new Criteria.
3.  I added this code during the very early stages of BasePeer, thinking
I would add more as other common sql patterns became known to me.  I
have not found any worth adding (too much logic for the frequency of
occurence.)
4.  It might be slightly confusing about how to get the "automatic" join
to appear.
5.  The OM/Peer classes add the join explicitely (I think.)

This will have an effect on the generated sql for people who were using
it (obviously), it could also change the sql in cases where someone
forgot the join and it was being added.

John McNally


------------------------------------------------------------
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
Search: <http://www.mail-archive.com/turbine%40list.working-dogs.com/>
Problems?:           [EMAIL PROTECTED]

Reply via email to