Bug #37179
Duplicate fields handling
| Status: | Closed | Start date: | 2012-05-15 | |
|---|---|---|---|---|
| Priority: | Should have | Due date: | ||
| Assignee: | Francois Suter | % Done: | 100% |
|
| Category: | Documentation | |||
| Target version: | 1.7.0 | |||
| Votes: | 0 |
Description
I need to use two static values with same name but different meaning in my query:
SELECT ('mystring') AS meaning1, ('mystring') AS meaning2 FROM myTable
When the query is checked I get an warning on the duplicate fields - however, the last static value wins and the first is discarded (so maybe the warning should be more clear that something will go wrong here). I can bypass this problem using different types of quotes:
SELECT ("mystring") AS meaning1, ('mystring') AS meaning2 FROM myTable
It should be possible to select double STATIC values, I think.
Associated revisions
Added note in the documentation about static values not being supported in queries, resolves #37179
Added note in the documentation about static values not being supported in queries, resolves #37179
History
Updated by Francois Suter about 1 year ago
- Category set to Query parsing
- Status changed from New to On Hold
Hi Rainer,
Actually dataquery was never meant to support static values. It's a feature we never needed and didn't even really think about. It could be implemented but it may require quite some work in improving the current SQL parser.
I don't think that we will implemented this in the near future, unless we suddenly have the need ourselves or such development is sponsored. Of course should you want to implement it yourself, your patch will be welcomed.
Updated by Rainer Becker about 1 year ago
Maybe you could add it to your - really outstanding - documentation. Sometimes I found it hard to find the point where things go wrong, as there are many players in a complex tesseract project.
®
Updated by Francois Suter about 1 year ago
- Category changed from Query parsing to Documentation
- Status changed from On Hold to Accepted
- Assignee set to Francois Suter
You're right, the least would be to add it to the documentation. That's feasible ;-)
It's true that it's sometimes hard to find information since Tesseract is spread over many extensions. I haven't yet found an ideal solution to this. Maybe with the planned move of the TYPO3 documentation to reStructured Text, it might be possible to retrieve all the rendered documentation on the Tesseract web site and create some kind of "compound" manual. We'll see.
There should be more tutorials too, but it takes such a long time to write...
Updated by Francois Suter 11 months ago
I just added a note to the manual about this. Interestingly enough, if you hadn't used brackets around your static values, the query would have failed, because it would have been rebuilt as:
SELECT myTable.'mystring' AS meaning1 ...
which would have triggered a SQL error. Brackets have made the values to be considered as functions, which is wrong, but I'm not sure how difficult (or not) it would be to educate the parser about this. I would need to look deeper into SQL allowed syntax.
Updated by Francois Suter 11 months ago
- Target version set to 1.7.0
Updated by Francois Suter 11 months ago
I'll stick with just a note in the manual. I just made a test and MySQL behaves the same whether a function call has a space in between function name and arguments or not, i.e. both
SELECT LENGTH(title)
and
SELECT LENGTH (title)
produce the same result. This makes it hard to tell apart a function from a field or a static value wrapped with brackets. An improved SQL parser is long desired feature, but we haven't had the need nor the resources yet.
Updated by Francois Suter 11 months ago
- Status changed from Accepted to Resolved
- % Done changed from 0 to 100
Applied in changeset r63616.
Updated by Francois Suter 11 months ago
- Status changed from Resolved to Closed