Author Topic: Adding persistent fields using the fields editor  (Read 1438 times)

llion

  • Newbie
  • Posts: 6
Adding persistent fields using the fields editor
« on: August 15, 2026, 04:08:48 pm »
I am migrating my application from Firebird to SQLite. One of the necessary changes is that database columns of type VARCHAR in Firebird are of type TEXT in SQLite, so that persistent fields corresponding to such columns need to be changed from TStringField to TMemoField. I do this by pulling up the Fields Editor in the Laz IDE (double-click on the TSQLQuery component on the form), delete the old field, then use Add Fields to create it again with the same name and as if by magic the new type. But here's the problem : I edited the SQL property in the TSQLQuery component, and the Fields Editor is ignoring the edited SQL. The list of fields available to add is taken from the old SQL, even though the edited SQL no longer selects those columns, and columns added to the selection in the new SQL are omitted/ignored. Laz appears to have got its knickers in a twist, has anyone else suffered this? The SQL SELECT includes a LEFT OUTER JOIN, and the fields pulled in from the joined table were early casualties, as if the join itself triggered something?
Any help/views would be much appreciated, before I delete the TSQLQuery component and redo from scratch.

LemonParty

  • Hero Member
  • *****
  • Posts: 657
Re: Adding persistent fields using the fields editor
« Reply #1 on: August 15, 2026, 05:47:05 pm »
Quote
I edited the SQL property in the TSQLQuery component, and the Fields Editor is ignoring the edited SQL
When you add fields automatically TSQLQuery query setted connection and than add fields based on this request. Are you sure you set the correct connection for your TSQLQuery?
Lazarus v. 4.99. FPC v. 3.3.1. Windows 11

paweld

  • Hero Member
  • *****
  • Posts: 1741
Re: Adding persistent fields using the fields editor
« Reply #2 on: August 17, 2026, 06:11:57 am »
Quote from: llion
One of the necessary changes is that database columns of type VARCHAR in Firebird are of type TEXT in SQLite, so that persistent fields corresponding to such columns need to be changed from TStringField to TMemoField.
This is indeed the case in the engine itself, but when defining a table, you can use the VARCHAR type with a specified field length, e.g., VARCHAR(20), and then that column will still be of type TStringField (rather than TMemoField).
So you won’t have to redefine the fields in TSQLQuery if you adjust the table structures accordingly.
Of course, you just need to remember that SQLite will still treat these columns (varchar) as TEXT and allow text of any length to be stored.
Best regards / Pozdrawiam
paweld

 

TinyPortal © 2005-2018