Bug 332329

Summary: Query may lose "table." prefix after switch to design view
Product: [Applications] KEXI Reporter: robert leleu <robert.jean.leleu>
Component: QueriesAssignee: Jarosław Staniek <staniek>
Status: CLOSED FIXED    
Severity: grave Keywords: release_blocker
Priority: NOR    
Version: 2.8.0   
Target Milestone: ---   
Platform: unspecified   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: that's the file «from 2.7.2»
and that's the corrupted one

Description robert leleu 2014-03-19 15:44:02 UTC
Kexi 2.8.0 is, for my datas, in heavy regression.
The central part of my application consists of 3 tables and 2 queries (each associated to a report)

Table identite has unique key idcleunik
Table liens has unique key licleunik
Table lieide links this 2 keys, with of course an occurence unique key

After some additions to the files there 3 oddities
1/ sometimes the SQL of the queries no longer shows the keys prefixed by the name of a table.
2/ After reinsertion of table names the Design view no longer shows the links. After redrawing of the links the data view is OK, but
3/ The queries no longer appears as available sources for the reports.

I have more detailed reports, but I've not been able to spot the problem.

I tried to return to 2.7.2 but synaptic requested that I repair the broken packets…. 
My files (before/after) could be sent.

Reproducible: Always

Steps to Reproduce:
1.I'll give later with my file, if requested
2.
3.
Comment 1 Jarosław Staniek 2014-03-19 15:47:04 UTC
Hi Robert, yes it will be useful to have samples from you.
Comment 2 Jarosław Staniek 2014-03-19 15:47:59 UTC
I set this bug as a release_blocker for 2.8.1.
Comment 3 robert leleu 2014-03-19 16:14:43 UTC
Created attachment 85637 [details]
that's the file «from 2.7.2»
Comment 4 robert leleu 2014-03-19 16:20:15 UTC
Created attachment 85638 [details]
and that's the corrupted one

The additions are
the last line in table liens with licleunik=1072
lines in table lieide with licleunik=1072
Links in queries design mode are between "??cleunik" of same names
Comment 5 Jarosław Staniek 2014-03-19 16:36:03 UTC
Thanks Robert. It's better for you to go back to 2.7.x until there's a fix.
Comment 6 robert leleu 2014-03-19 17:11:00 UTC
la 19/03/2014 17:36, Jarosław Staniek skribis (esperanto estas la unua 
internacia lingvo)
> https://bugs.kde.org/show_bug.cgi?id=332329
>
> --- Comment #5 from Jarosław Staniek <staniek@kde.org> ---
> Thanks Robert. It's better for you to go back to 2.7.x until there's a fix.
>

So, I desactivated deb-src 
http://ppa.launchpad.net/kubuntu-ppa/backports/ubuntu/ saucy main and 
recovered the 2.7.2
Good luck, and thanks for being so reactive
Comment 7 Jarosław Staniek 2014-03-19 18:44:50 UTC
Perhaps related to this change of behavior: https://bugs.kde.org/show_bug.cgi?id=331259. I guess I am on right track.
Comment 8 robert leleu 2014-03-19 21:03:37 UTC
I just had a glance at 2.9 within NEON   . The bug is there.
Comment 9 Jarosław Staniek 2014-03-19 21:05:19 UTC
2.9 is Pre-Alpha now (calligra master branch) so yes, it's unfixed. Your case helps a lot, not for the first time :)
Comment 10 Jarosław Staniek 2014-03-19 21:57:52 UTC
I am focused on the " sometimes the SQL of the queries no longer shows the keys prefixed by the name of a table" part of the report, hoping the rest may be related to this misbehavior.
Comment 11 robert leleu 2014-03-20 08:47:02 UTC
indeed that's the case of the corrupted files

I'm presently  adding my new datas to the file under 2.7.2, and something has not been clear. I'll do again .
Could the problem (at least part of it)  be in the file ? 

Is there a way to launch a verbose Kexi ?
Comment 12 Jarosław Staniek 2014-03-20 09:29:50 UTC
@Robert I'd like to keep this bug report devoted to one issue, if there's something else (corruption?) I encourage to discuss it in details on the forum first, then maybe file another bug report when we can spot the issue.
Comment 13 Jarosław Staniek 2014-03-22 23:11:41 UTC
The test file https://bugs.kde.org/attachment.cgi?id=85637&action=edit has query 'liensidentite' that's already invalid:
SELECT civilite, nom, prenom, courriel, adresse1, adresse2, code, commune, trilien, licleunik, idcleunik, remarque, idcleunik FROM lieide, identite, liens, localis, codecomm, pays WHERE (codecomm.cocleunik = localis.cocleunik AND localis.locleunik = identite.locleunik AND identite.idcleunik = lieide.idcleunik AND liens.licleunik = lieide.licleunik AND pays.pacleunik = codecomm.pacleunik) AND (liens.licleunik = 48) ORDER BY identite.nom, identite.prenom

The reason why it's invalid: "Both table "lieide" and "liens" have defined "licleunik" field. Use ".licleunik" notation to specify table name."

I reduced the test to a query "SELECT identite.idcleunik FROM lieide, identite WHERE identite.idcleunik = lieide.idcleunik". Note the use of "identite." prefix. So the query is valid. The query 'liensidentite' can be fixed the same way.

Switching to design view breaks the fix and we're again with invalid query. Forthcoming fix addresses this.
Comment 14 Jarosław Staniek 2014-03-22 23:30:30 UTC
Review of a fix is in progress: https://git.reviewboard.kde.org/r/116986/
Comment 15 Jarosław Staniek 2014-03-22 23:32:43 UTC
@Robert: Changed name of this bug. Should you have separate bugs we'll need them reported separately.
Comment 16 Jarosław Staniek 2014-03-23 21:19:10 UTC
Git commit bdab8c724e91e59e247835ea1cc7dbacf39f752e by Jaroslaw Staniek.
Committed on 22/03/2014 at 23:11.
Pushed by staniek into branch 'calligra/2.8'.

Do not remove table prefix when it is needed
REVIEW:116986

M  +2    -1    libs/db/connection.cpp
M  +5    -4    libs/db/expression.cpp

http://commits.kde.org/calligra/bdab8c724e91e59e247835ea1cc7dbacf39f752e
Comment 17 Jarosław Staniek 2014-03-23 21:20:08 UTC
Git commit 5728406cd72a42add30163cba03cdcd643febfd2 by Jaroslaw Staniek.
Committed on 22/03/2014 at 23:11.
Pushed by staniek into branch 'master'.

Do not remove table prefix when it is needed

M  +2    -1    libs/db/connection.cpp
M  +5    -4    libs/db/expression.cpp

http://commits.kde.org/calligra/5728406cd72a42add30163cba03cdcd643febfd2
Comment 18 robert leleu 2014-03-24 10:05:33 UTC
So I understand that master (and NEON) includes yet the correction.

For Mint I'll check for the next upgrade of calligra in https://launchpad.net/~kubuntu-ppa/+archive/backports/+packages

Thanks