Recent

Author Topic: Issue with global find/replace affecting SQL query  (Read 310 times)

Graham Saint

  • Newbie
  • Posts: 4
Issue with global find/replace affecting SQL query
« on: July 20, 2022, 12:35:34 pm »
Not sure if this counts as a bug but I think it's an issue worth mentioning.
I recently did a global find/replace on all files in  my project. In doing this I accidently renamed a SQL query that was in a data module. For some reason the rename affected the SQL query in the data module's unit source but not in the data module's form view.
So if you viewed the module's form the query was SQL1 but in the unit source it was renamed to SQLX.
The net result of this was that the program crashed with an addressing exception  when it attempted to use one the query's methods.
I'm a bit surprised that the program was able to compile.
Is this a known issue?

af0815

  • Hero Member
  • *****
  • Posts: 1018
Re: Issue with global find/replace affecting SQL query
« Reply #1 on: July 20, 2022, 01:12:30 pm »
It is not a issue, if have it renamed by hand. A search and replace only will create mess. The crash is inside the reader, because it found not the renamed component. It was only renamed in source but not in the lfm.

Always use F2 or use Menu Souce->Refactoring->Renemame Identifier.
regards
Andreas

dseligo

  • Hero Member
  • *****
  • Posts: 706
Re: Issue with global find/replace affecting SQL query
« Reply #2 on: July 20, 2022, 01:27:59 pm »
It is not a issue, if have it renamed by hand. A search and replace only will create mess. The crash is inside the reader, because it found not the renamed component. It was only renamed in source but not in the lfm.

Always use F2 or use Menu Souce->Refactoring->Renemame Identifier.

While I agree that using search and replace will create mess, you are wrong about using F2 and refactoring.
Components on the form aren't updated using F2 - you have to use Object inspector to rename components on the form.

I would like that form components are also renamed with F2, but I don't know if it is intentional like that or a bug.

af0815

  • Hero Member
  • *****
  • Posts: 1018
Re: Issue with global find/replace affecting SQL query
« Reply #3 on: July 20, 2022, 02:02:48 pm »
While I agree that using search and replace will create mess, you are wrong about using F2 and refactoring.
Components on the form aren't updated using F2 - you have to use Object inspector to rename components on the form.
sorry, you are right, but it was so an automated task by me
regards
Andreas

Graham Saint

  • Newbie
  • Posts: 4
Re: Issue with global find/replace affecting SQL query
« Reply #4 on: July 21, 2022, 05:57:25 am »
I used global find/replace because I had a bunch of type definitions in a low level unit that many other units referenced. As the program grew it became clear that the original names chosen weren't the best and I decided to give them better ones. Doing this by hand would have been a very long process. In hindsight I should have used the "Whole Words Only" option but I didn't think I needed to.
I'd class this as a bug, albeit an obscure one, because throwing the lfm and source out of alignment resulted the program crashing without warning. Maybe the compiler could check for an inconsistency and issue a warning?

af0815

  • Hero Member
  • *****
  • Posts: 1018
Re: Issue with global find/replace affecting SQL query
« Reply #5 on: July 21, 2022, 06:47:35 am »
I'd class this as a bug, albeit an obscure one, because throwing the lfm and source out of alignment resulted the program crashing without warning. Maybe the compiler could check for an inconsistency and issue a warning?
I think its not for the compiler, because the syntax is rigth, but the code and resources are not in sync. Code alone is valid, lfm alone is valid. Have you ever switched between the code/form in Lazarus after a reload of the broken project ?! Normal, you should have troubles there.
regards
Andreas

 

TinyPortal © 2005-2018