Hi,
Imagine a select query select a.*, b.* from a inner join b
If the user update one field of a, or one field of b using update grid, update criteria is easy to guess :
it is the a.primarykey field (or several pk if pk is on several columns).
So instead of displaying "no update criteria selected", if update criteria isn't ambigous, it would be great if it was directly defined ..
Here my patch that works only if you display one table for update
ContentPane.java
public void actionPerformed(ActionEvent ae)
{
if(ContentPane.this.getUpdateModel() ==null)
{
UpdateModel um = new UpdateModel();
TableMetaData tmd;
Vector rowid = new Vector();
QueryTokens._Expression[] e = qmodel.getQueryExpression().getQuerySpecification().getSelectList();
for(int j=0; j<e.length; j++)
{
if(e[j] instanceof QueryTokens.Column)
{
QueryTokens.Column c = (QueryTokens.Column)e[j];
//c.getTable()
tmd = new TableMetaData( getHandlerKey(),c.getTable().getSchema(),c.getTable().getName());
if(tmd.isPrimaryKey(c.getName()))
{
rowid.addElement(c);
um.setTable(c.getTable());
}
//System.out.println(b);
}
}
QueryTokens.Column[] c = new QueryTokens.Column[rowid.size()];
um.setRowIdentifier((QueryTokens.Column[])rowid.toArray(c));
ContentPane.this.setUpdateModel(um);
}
if(ContentPane.this.getUpdateModel() !=null && ContentPane.this.getUpdateModel().getRowIdentifierCount() > 0)
{
doUpdate();
}
----------------------
I hav seen a bug in TaskUpdate.java . The name of the field updated was tablea_fielda whereas it should be tablea.fielda .
Here the second patch :
else if(handler.type.equals(ContentChanges.UPDATE))
{
for(int i=0; i<rowdata.length ; i++)
{
String cname;
if(rowdata[i] instanceof Object[])
{
Object cell = ((Object[])rowdata[i])[0];
params.addElement(new Object[]{cell, new Integer(target.getView().getColumnType(i))});
QueryTokens._Expression[] e = target.getQueryModel().getQueryExpression().getQuerySpecification().getSelectList();
if(e[i] instanceof QueryTokens.Column)
{
QueryTokens.Column c = (QueryTokens.Column)e[i];
cname = "`"+c.getTable().getName()+"`.`"+c.getName()+"`";
}
else cname = target.getView().getColumnName(i);
columns.addElement(SQLFormatter.ensureQuotes(cname,ch.getObject("$identifierQuoteString").toString(),true));
}
}
sql = target.getUpdateModel().getUpdateSyntax((String[])columns.toArray(new String[columns.size()]));
}