I have an object 'xbrowse', using tdolphin. The main query has a relationship between tables, which coincidentally has a field in the table with the same name: "key". But this field is not part of the query.
SELECT p.key, p.data, c.name FROM orders AS p LEFT JOIN customers AS c ON(c.code=p.code)
the browse works fine, however when clicking on the header (autosort) of the "key" column, an error is generated.
Note: When clicking on the header of the 'key' column, internally xbrowse does:
SELECT * FROM orders AS p LEFT JOIN customers AS c ON(c.code=p.code) ORDER by key
I believe this is the problem. How can I solve the situation?
example:
estrutura:
table pedidos:
chave
data
codigo
table clientes:
codigo
nome
chave
oQry := oServer:Query('SELECT p.chave, p.data, c.nome FROM pedidos AS p LEFT JOIN clientes AS c ON(c.codigo=p.codigo)'
@ 0,0 XBROWSE oBrowse OF oDialog OBJECT oQry AUTOCOLS AUTOSORT LINES
with object oBrowse:oCol(1)
:cHeader := 'Chave'
:cEditPicture := '@!'
:bEditValue := {|| oQry:chave}
end
with object oBrowse:oCol(2)
:cHeader := 'Data'
:cEditPicture := '@!'
:bEditValue := {|| oQry:data}
end
Error description: Error MYSQL/1052 Column 'chave' in order clause is ambiguous
Stack Calls
===========
Called from: .\source\prg\tdolpsrv.prg => DOLPHIN_DEFERROR( 2807 )
Called from: .\source\prg\tdolpsrv.prg => TDOLPHINSRV:CHECKERROR( 793 )
Called from: .\source\prg\tdolpsrv.prg => TDOLPHINSRV:SQLQUERY( 2024 )
Called from: .\source\prg\tdolpqry.prg => TDOLPHINQRY:LOADQUERY( 1145 )
Called from: .\source\prg\tdolpqry.prg => TDOLPHINQRY:SETNEWFILTER( 1577 )
Called from: .\source\prg\tdolpqry.prg => (b)TDOLPHINQRY( 237 )
Called from: .\source\prg\tdolpqry.prg => TDOLPHINQRY:SETORDER( 0 )
Called from: xbrowse.prg => TXBRWCOLUMN:SETORDER( 17428 )
Called from: xbrowse.prg => TXBRWCOLUMN:HEADERLBUTTONUP( 15938 )
Called from: xbrowse.prg => TXBROWSE:LBUTTONUP( 5157 )
Called from: .\source\classes\control.prg => TCONTROL:HANDLEEVENT( 1851