#225 Line wrap in generated select statement destroys quoting for column names


The names of the columns in my table contain spaces, therefore quoting is essential.
The select statement generated from "browse data" is word wrapped in the "sel"-window, disregarding the quotes ("view" -> "wrap long lines" does not change anything) - looks like this:

SELECT r."Res A lower", r."Res A upper", r."Res B lower", r."Res B upper", r."Res C
lower", r."Res C upper", r."Res D lower", r."Res D upper", r."Time (UTC)",
r."Time (local)"
FROM "Citobloc-Raw" r

of course I get something like:

Dynamic SQL Error
SQL error code = -206
Column unknown
R.Res C
At line 1, column 73

until I fix the quotes manually.


  • Miroslav Policki

    Here's an easy way to confirm the bug. Execute the following code:

    create table test (testcol int);
    create view testview as
    SELECT test.testcol AS "a a a a a a a", test.testcol AS "a a a a a a a a a a a a a a a b", test.testcol AS "a a a a a a a a a a a a a a a c"
    from test;

    Now right-click on TESTVIEW and select Browse data.

    UPDATE: I've discovered that you can prevent line-wrapping of generated code (at least in this case) if you go to View -> Preferences -> SQL Editor and set "Draw long line marker after column" to 0. It doesn't seem to matter if "Show long line marker" is ticked or not.

    Also, after digging through the code a bit, I think I've found that the root of the problem is wrapText in StringUtils.cpp, which is only aware of words, but not quotes. wrapText implements the %wrap template command which is used in the file browse_data.template to wrap the SELECT part of the statement. The file is in turn processed in MainFrame::executeSysTemplate when called from MainFrame::OnMenuBrowseData.

    Last edit: Miroslav Policki 2013-10-12
  • Michael Hieke

    Michael Hieke - 2013-10-13
    • status: open --> closed
    • assigned_to: Michael Hieke
  • Michael Hieke

    Michael Hieke - 2013-10-13

    Fixed in git commit 08d0ad8



Cancel  Add attachments