mariuz / flamerobin

FlameRobin is a database administration tool for Firebird RDBMS. Our goal is to build a tool that is: lightweight (small footprint, fast execution) cross-platform (Linux, Windows, Mac OS X, FreeBSD) dependent only on other Open Source software
http://flamerobin.org
MIT License
216 stars 67 forks source link

Problem with "Browse data" functionality: space is translated to a linebreak #366

Closed oliwe closed 9 months ago

oliwe commented 9 months ago

Just upgraded from version 0.9.3 to 0.9.10. In the new Version a bug in the "Browse data" funktionality is introduced. The problem is a field variable with a space in it: "E/I MLA" - this was never a problem in previous versions of flamerobin. Now when creating the SELECT call, a space is converted into a linebreak. Manually replacing the linebreak with a space fixes the problem.

flamerobin_bug_browse_data_with spaces

arvanus commented 9 months ago

Hi, can you provide an reproducible example? I tried with this, and worked:

CREATE TABLE table_name
(
    "E/I MLA" integer
);
oliwe commented 9 months ago

Yes - I have the table created and I am working with the table since a log time :-) What does not work is if I do a right click on the table and choose "Browse data" then the SELECT statement is not build correctly. A linebreak is introduced after E/I. This leads to the SQL error code = -206

Replacing the linebreak manually fixes the problem. If I copy the select statement in my notepad++ and enable "Show everything" I can see CRLF behind E/I - and this is wrong. In my case the variable is a float.

This problem was not in the 0.9.3 version I used before.

arvanus commented 9 months ago

If you try to recreate this column in a new table, you get the same problem? (please don't copy and paste, retype manually the column name) Also if yes, can you send me a step-by-step to try here? Because I'm unable to reproduce here Also, which Fb version are you using? Can you provide the output of this SQL?

select 
      BASE64_ENCODE(trim(f.RDB$FIELD_NAME)),  --remove this line if Fb <= 3.0
      f.* from RDB$RELATION_FIELDS f
where f.RDB$RELATION_NAME=:yourtable
and f.RDB$FIELD_NAME=:yourProblematicColumn
oliwe commented 9 months ago

I removed the column and readded it. Same problem. Firebird 3.0.10.33601 But it looks like a probem in flamerobin - as I wrote ealier "just" the SELECT statement is wrong. By manually replacing the linebreak with a space fixes the problem:

flamerobin_bug_browse_data_with spaces_corrected

select BASE64_ENCODE(trim(f.RDB$FIELD_NAME)), f.* from RDB$RELATION_FIELDS f where f.RDB$RELATION_NAME=:"yct_parenchyma" and f.RDB$FIELD_NAME=:"E/I MLA"

results in

Error: IBPP::LogicException Context: Statement::FindParamsByName Message: Parameter name not found.

oliwe commented 9 months ago

BTW When I do a right click on the table "yct_parenchyma" then "Generate Code" and then "SELECT ... from yct_parenchma where ..." and I choose "E/I MLA" then flamerobin generates

SELECT a."E/I MLA" FROM "yct_parenchyma" a ;

and this works :-)

So the problem only occures if the whole table should be shown - maybe a length problem?

arvanus commented 9 months ago

where f.RDB$RELATION_NAME=:"yct_parenchyma" and f.RDB$FIELD_NAME=:"E/I MLA"

remove ":", its for passing as parameter

Also, can you pass me the DDL from this table? Right click->Generate Code->Extract full DLL for table

oliwe commented 9 months ago

select BASE64_ENCODE(trim(f.RDB$FIELD_NAME)), f.* from RDB$RELATION_FIELDS f where f.RDB$RELATION_NAME="yct_parenchyma" and f.RDB$FIELD_NAME="E/I MLA"

gives me

Dynamic SQL Error SQL error code = -206 Column unknown E/I MLA At line 5, column 22

yct_parenchyma_ddl.txt

arvanus commented 9 months ago

try using single quote


select
BASE64_ENCODE(trim(f.RDB$FIELD_NAME)),
f.* from RDB$RELATION_FIELDS f
where f.RDB$RELATION_NAME='yct_parenchyma'
and f.RDB$FIELD_NAME='E/I MLA' --if needed, remove this line
arvanus commented 9 months ago

Could replicate here, I'll take a look ASAP

arvanus commented 9 months ago

found the bug, tricky one :)

when there is a case where the SQL extrapolates the (default) 80 max char col size, and a word with space is wrapped with a quote, and you are in the second line, it'll wrongly wrap to the third line breaking the quoted string

arvanus commented 9 months ago

try the latest snapshot build from here: https://github.com/mariuz/flamerobin/actions/runs/7715391998

oliwe commented 9 months ago

I tested the snapshot - the problem seems to be solved. Thank you for the quick bug fix :-)