developer.jelix.org n'est plus utilisée, et existe uniquement pour son historique. Postez les nouveaux tickets sur le compte github.
Opened 9 years ago
Last modified 9 years ago
#1436 assigned bug
jDao : a notice is dropped on insert() when having an "insertpattern" on a PK and on a regular field
Reported by: | bricet | Owned by: | bricet |
---|---|---|---|
Priority: | normal | Milestone: | |
Component: | jelix:dao | Version: | 1.3.0 |
Severity: | normal | Keywords: | |
Cc: | Blocked By: | ||
Blocking: | Documentation needed: | no | |
Hosting Provider: | Php version: |
Description
In a dao, if you have an "insertpattern" on a PK and on a regular field, this leads to a notice (Trying to get property of non-object) on insert().
This is due to a SELECT generated to get the value of insertpattern'ed regular field (this request does not return anything as there is a WHERE clause on PK, and insertpattern'ed PK's value is not known).
This SELECT request is not generated if a PK has an insertpattern and regular fields does not. I guess we should have a system to get the value in those cases too.
To my point of view, the only way to solve the problem (keeping current functionnalities) would be to make a dummy request (e.g. "SELECT NOW()" in MySQL) to get PK insertpattern'ed value(s), then use those values on the INSERT and, if needed, in the SELECT's WHERE-clause.
Change History (5)
comment:1 Changed 9 years ago by bricet
comment:2 Changed 9 years ago by laurentj
In a dao, if you have an "insertpattern" on a PK
insertpattern is forbidden on a PK; It does not make sens.
comment:3 Changed 9 years ago by bricet
Jelix does not report an "insertpattern" on a PK as being forbidden.
And for me, it could be usefull to make actions or methods simplier (and more bullet-proof). E.g. I have DATE_FORMAT(NOW(), \'%%Y-%%m\') as an insertpattern on one of PK's fields because I want a key to be distinguished for each month.
comment:4 Changed 9 years ago by bricet
Just FYI, in #923 you mentionned "Why not to have an insertpattern for a primary key which is not auto incremented"
Yes, I want it ... ;)
comment:5 Changed 9 years ago by laurentj
- Owner set to bricet
- Status changed from new to assigned
Added a (dirty - i.e. using existing tables in testapp) testcase to show troubles in https://github.com/jelix/jelix/pull/6