View Issue Details

IDProjectCategoryView StatusLast Update
0031965LazarusDatabase Componentspublic2017-11-17 22:31
Reporterertank Assigned ToJuha Manninen  
Status resolvedResolutionfixed 
PlatformRaspberry Pi 3, x86_64OSRaspbian, Windows 
Product Version1.8RC1 
Summary0031965: TSQLQuery.Params[0].Value assignment or changing TSQLQuery.Params[0].Value.Type does not work
DescriptionBoth on Windows 10 64bit and Lazarus 64bit, or Raspberry Pi 3 and Lazarus doesn't work.

Database server is PostgreSQL 9.4.10 on Raspberry Pi 3
Steps To ReproduceI have following text in my SQLQuery1.SQL
Code: [Select]
select * from test where abc = :param

All below is at design time. I am using object inspector;
-Click Params (new windows pops: Editing SQLQuery1.Params[0])
-Click 0 - param to set parameter "param" (Object Inspector changes into TParam properties)
-Click Value and type something.

1- When I hit Enter Value reverts back to "(Null)"
2- When I try to set a Parameter Value Type it simply reverts back to "Null"
Additional InformationIt is not just Object Inspector that cannot assign a parameter value, parameters are not assigned using code, too.

For attached project, I have log_statement = 'all' in my postgresql.conf to understand better what's going on.
TagsNo tags attached.
Fixed in Revisionr56035, r56146
WidgetsetGTK 2
Attached Files


related to 0019324 resolvedJuha Manninen propedits.pp - TPropertyEditor with Variants not working, TVariantPropertyEditor commented out 
related to 0028040 resolvedJuha Manninen TLRSObjectWriter is missing implementation of WriteVariant 
related to 0025068 assignedJuha Manninen Modifying CollectionItem does not mark the edited file as modified. (was:Changing ContentProducer property in OI has no effect) 
related to 0032705 resolvedJuha Manninen TSQLQuery.Params are not updating at design-time 



2017-06-04 14:29



2017-06-04 14:46

reporter   ~0100857

Just wanted to add that Lazarus 1.6.4 (SVN 55188) works OK.


2017-06-12 07:04


bug31965.lpr (928 bytes)


2017-06-12 07:05

developer   ~0101044

Can you try attached "bug31965.lpr" what results do you get?
If you get correct results, can you alter "bug31965.lpr" to show bug ?


2017-06-14 19:08

reporter   ~0101130

Bug is at design time. You cannot set a parameter value at design time using Object Inspector.

Juha Manninen

2017-10-09 15:30

developer   ~0103286

Does the problem happen only in Raspberry Pi? I understood LacaK could not reproduce.
If Lazarus 1.6.4 is OK, you could try bisecting the guilty revision:

Otherwise please provide test project without PostgreSQL dependency. I guess the bug is not related to it.


2017-10-09 15:37

developer   ~0103287

I can not reproduce in FPC only (confirmed by reporter, that bug is in design time only)
TParam.Value is published *Variant* property ...

Juha Manninen

2017-10-09 23:37

developer   ~0103317

I will not install PostgreSQL for this. I hope there is a way to test without it.


2017-10-11 08:25

developer   ~0103350

Last edited: 2017-10-11 08:48

View 6 revisions

I think, that you are not required to install PostgreSQL.
IMO problem may be reproducible with any TCustomSQLQuery (descendant) component with any TSQLConnection descendant on any platform (not only RPi).

May be this help:
TCustomSQLQuery.Params is declared of type TParams (collection of TParam), but object created at runtime is always of type TSQLDBParams (is descendant from TParams i.e.=class(TParams)) and item in this collection is of type TSQLDBParam

Btw. you can reproduce it without PostgreSQL:
- Open attached project1 (in
- Click in Object inspector on "SQLQuery1: TSQLQuery"
  "FieldDefs: TSQLDBFieldDefs" changes to "<unknow collection>: TSQLDBFieldDefs" ?
- Then click on "Params" property and on "0-param"
- Try change Value to any numeric value.
  You will see, that (Null) is set back ...
  (Also when you save form, form is damaged, because there is:
    Params = <
        DataType = ftInteger
        Name = 'param'
        ParamType = ptInput
        Value = <---
      end> )


2017-10-11 08:43

developer (2,272 bytes)

Juha Manninen

2017-10-11 16:53

developer   ~0103361

Ok, I can reproduce...

Juha Manninen

2017-10-12 13:37

developer   ~0103378

Please test with r56035.


2017-10-13 05:45

developer   ~0103395

In r56036 is resolved only problem with:
 "FieldDefs: TSQLDBFieldDefs" changes to "<unknow collection>: TSQLDBFieldDefs"

There are still problems with "0-param".Value:
- When I change value of Value or any other property (like Size, Precision, Name etc.) in Object inspector then in toolbox (and main menu) is not enabled Save (Ctrl+S) button ... seems like change is not catched
- When I change value of Type property (under Value property) to Unassigned or Null and save form , form becomes corrupted as I wrote above (you cannot open it later)

Juha Manninen

2017-10-13 16:14

developer   ~0103412

Did it work at some point?


2017-10-13 19:02

developer   ~0103415

Last edited: 2017-10-16 05:17

View 3 revisions

In Lazarus 1.6.4 (FPC 3.0.2) it does not work, but behaves differently. When I try to change Value error dialog is shown "Could not convert variant of type (Null) ..." and only option is press Esc to cancel change. Later when I save form, form is NOT corrupted (Value property is not present in LFM file of course).
When I change value of any other property Save is also not enabled.

In Lazarus 1.4.4 (FPC 2.6.4) when I click "0-param" there is no Value property in object inspector at all!
When I change value of any other property Save is also not enabled.

So conclusion: none of above mentioned versions works correctly, but none cause LFM corruption. It is hard to fix this bug in trunk? (I do not know what is root of problem, streaming NULL variant values or ?)

Juha Manninen

2017-10-16 13:49

developer   ~0103475

> It is hard to fix this bug in trunk?

I believe it is easy if you know how to do it. :)
I don't know it but I will debug it at some point.
BTW, nobody maintains the DB stuff very actively. Many bug reports are open since 8+ years.
If somebody provides well tested patches, I can apply.

Juha Manninen

2017-10-22 16:22

developer   ~0103686

I fixed the TVariantPropertyEditor in r56146. I had applied its initial implementation by Michal Gawrycki a year and a half ago. Didn't even remember.
Please test.

Now the LFM does not corrupt any more but I am still puzzled of what is going on.
In your example app I can add Params in the property editor and set their values. After I save the project I can see they are stored in LFM file. Good.
However when I open the project again it only shows the one Param that was there already. The others are ignored. Is the one saved also somewhere else?
Changes in FieldDefs are stored OK. It is also shown in the component treeview. Why params are not there? Uhhh...


2017-10-23 05:45

developer   ~0103708

Yes, I can confirm that LFM is okay.
Only small cosmetic problem is with "Save" (as I wrote when I change something in "param" Save button is not enabled ... I must go to owner component and there do any change)

There is IMO no problem, when you add params and save LFM and restore, that newly added params are mising ... it is like TSQLQuery works ... Params are built based on SQL text in SQL property ... so sql statement is parsed and params are put in TParams collection.

So from my POV root problem is fixed ... may be this is candidate for merging in 1.8.x branch

Juha Manninen

2017-10-23 07:35

developer   ~0103710

> So from my POV root problem is fixed ... may be this is candidate for merging in 1.8.x branch

Yes, the 2 revisions are already merged. This was a major bug anyway, and partly a regression.
I try to figure out the remaining Save-button issue. I guess it is common with many Collection properties.

Juha Manninen

2017-10-24 10:57

developer   ~0103734

Continuing the Save-button issue in 0025068.


2017-11-17 22:08

reporter   ~0104164

Last edited: 2017-11-17 22:09

View 2 revisions

I just checked with Lazarus 1.8.0.RC5 SVN 56257 and problem is still present.

- Open new project
- Put a TSQLQuery on the form.
- Write following in SQL property: "select * from abc where id = :id"
- Go to params property and click "0 - id"
From this point on all of the following failed for me:
1- Directly type something in Value (it stays as Null)
2- Change DataType to ftString and write something in Value (it stays as Null)
3- Change Value.Type to String (it is not changing to string)

Basically, I could not set a value for a parameter at design time.

Juha Manninen

2017-11-17 22:29

developer   ~0104165

It works here.
There is no 1.8.0.RC5 r56257. That revision came after RC5.
Test either with fixes_1_8 branch or with trunk directly from SVN server.

Issue History

Date Modified Username Field Change
2017-06-04 14:29 ertank New Issue
2017-06-04 14:29 ertank File Added: sqlquery_param_problem.rar
2017-06-04 14:46 ertank Note Added: 0100857
2017-06-12 07:04 LacaK File Added: bug31965.lpr
2017-06-12 07:05 LacaK Note Added: 0101044
2017-06-14 19:08 ertank Note Added: 0101130
2017-10-09 15:30 Juha Manninen LazTarget => -
2017-10-09 15:30 Juha Manninen Note Added: 0103286
2017-10-09 15:30 Juha Manninen Assigned To => Juha Manninen
2017-10-09 15:30 Juha Manninen Status new => feedback
2017-10-09 15:37 LacaK Note Added: 0103287
2017-10-09 23:37 Juha Manninen Note Added: 0103317
2017-10-11 08:25 LacaK Note Added: 0103350
2017-10-11 08:34 LacaK Note Edited: 0103350 View Revisions
2017-10-11 08:34 LacaK Note Edited: 0103350 View Revisions
2017-10-11 08:41 LacaK Note Edited: 0103350 View Revisions
2017-10-11 08:43 LacaK File Added:
2017-10-11 08:45 LacaK Note Edited: 0103350 View Revisions
2017-10-11 08:48 LacaK Note Edited: 0103350 View Revisions
2017-10-11 16:53 Juha Manninen Note Added: 0103361
2017-10-11 16:54 Juha Manninen Status feedback => assigned
2017-10-12 13:37 Juha Manninen Note Added: 0103378
2017-10-12 13:37 Juha Manninen Status assigned => feedback
2017-10-13 05:45 LacaK Note Added: 0103395
2017-10-13 16:14 Juha Manninen Note Added: 0103412
2017-10-13 19:02 LacaK Note Added: 0103415
2017-10-16 05:14 LacaK Note Edited: 0103415 View Revisions
2017-10-16 05:17 LacaK Note Edited: 0103415 View Revisions
2017-10-16 13:49 Juha Manninen Note Added: 0103475
2017-10-22 13:26 Juha Manninen Relationship added related to 0019324
2017-10-22 16:03 Juha Manninen Relationship added related to 0028040
2017-10-22 16:22 Juha Manninen Note Added: 0103686
2017-10-23 05:45 LacaK Note Added: 0103708
2017-10-23 07:35 Juha Manninen Note Added: 0103710
2017-10-23 07:35 Juha Manninen Status feedback => assigned
2017-10-24 10:55 Juha Manninen Relationship added related to 0025068
2017-10-24 10:57 Juha Manninen Fixed in Revision => r56035, r56146
2017-10-24 10:57 Juha Manninen Note Added: 0103734
2017-10-24 10:57 Juha Manninen Status assigned => resolved
2017-10-24 10:57 Juha Manninen Resolution open => fixed
2017-11-17 22:08 ertank Note Added: 0104164
2017-11-17 22:09 ertank Note Edited: 0104164 View Revisions
2017-11-17 22:29 Juha Manninen Note Added: 0104165
2017-11-17 22:31 Juha Manninen Relationship added related to 0032705