grifart libs issueshttps://gitlab.grifart.cz/groups/grifart/-/issues2023-11-01T12:28:27Zhttps://gitlab.grifart.cz/grifart/scaffolder/-/issues/29Make "Preserve" a core feature2023-11-01T12:28:27ZDaniel Kurowskidaniel.kurowski@grifart.czMake "Preserve" a core featureWhen I want to preserve a method, I have to call `->with(preserveAnotatedMethods())` to allow such behavior. Which is weird because you need to turn something on to turn something on. This scenario happens to me from time to time:
- wri...When I want to preserve a method, I have to call `->with(preserveAnotatedMethods())` to allow such behavior. Which is weird because you need to turn something on to turn something on. This scenario happens to me from time to time:
- write a `.definition.php`
```
return valueObject(Something::class, [
'field' => 'string',
]);
```
- run it
- annotate `#[Preserve]` and make changes
- run definition again to check it survived
- preserved methods are gone because of forgotten `->with(preserveAnotatedMethods())` call
Of course, `valueObject()` could contain `preserveAnotatedMethods()` (and it does), however I've still experienced this few times as I don't work only with `valueObject()`.
As this would be backwards compatible change (only methods annotated with that attribute will be preserved), I can see no reason why it has to be applied explicitely.
Any opinions? @jkuchar1 @jpudilhttps://gitlab.grifart.cz/grifart/tables/-/issues/29Find/get methods conventions2024-03-28T08:30:29ZJiří Pudilme@jiripudil.czFind/get methods conventionsChtěl bych vykopnout diskuzi ke konvencím v pojmenování metod pro získávání dat ve vygenerované implementaci `Table`. A taky doplnit některé, které tam občas postrádám.
V současnosti máme tyhle:
```
find($primaryKey): Row|null
get($pri...Chtěl bych vykopnout diskuzi ke konvencím v pojmenování metod pro získávání dat ve vygenerované implementaci `Table`. A taky doplnit některé, které tam občas postrádám.
V současnosti máme tyhle:
```
find($primaryKey): Row|null
get($primaryKey): Row
getAll($orderBy, $paginator): Row[]
findBy($conditions, $orderBy, $paginator): Row[]
getBy($conditions): Row
```
Narážím na to, že občas potřebuju vybrat jeden řádek splňující unikátní podmínku (use case pro `getBy`), který ovšem nemusí existovat. Momentálně to obcházím tak, že zavolám `findBy()`, zkontroluju si počet a vyberu z pole první prvek. Ale bylo by fajn na to mít metodu.
Dvojice `find()` a `get()` už tak trochu nastavuje očekávání, že `find*` vrací řádek nebo null, zatímco `get*` vrací řádek nebo výjimku. Takže když mám `getBy`, obdobná nullable metoda by se měla jmenovat... `findBy`? :thinking: napadlo mě tedy v názvu metody explicitně říct, že chci jeden záznam:
```
getOneBy($conditions): Row
findOneBy($conditions): Row|null
```
Metody by tak jako doposud vyhazovaly výjimku, pokud najdou více než jeden odpovídající řádek. To taky není vždycky žádoucí, takže bych si k nim dovolil doplnit ještě dvojici metod, kterým by nevadilo, když najdou víc odpovídajících řádků: vrátily by prostě první z nich podle nastaveného řazení:
```
getFirstBy($conditions, $orderBy): Row
findFirstBy($conditions, $orderBy): Row|null
```
Výsledná kompletní sada by tedy byla tato:
```
get($primaryKey): Row
find($primaryKey): Row|null
getOneBy($conditions): Row
findOneBy($conditions): Row|null
getFirstBy($conditions, $orderBy): Row
findFirstBy($conditions, $orderBy): Row|null
getAll($orderBy, $paginator): Row[]
findBy($conditions, $orderBy, $paginator): Row[]
```
Thoughts @jkuchar1 @dkurowski ?Jiří Pudilme@jiripudil.czJiří Pudilme@jiripudil.czhttps://gitlab.grifart.cz/grifart/stateful/-/issues/15Required interface of serialisation objects2023-10-27T11:32:35ZJan Kuchařhonza.kuchar@grifart.czRequired interface of serialisation objectsNow, there is always a Serializable interface required to be serializable. This works, until there are more than one places in the app where things are stored.
In CampApp for example there is routing/session configuration of stateful & ...Now, there is always a Serializable interface required to be serializable. This works, until there are more than one places in the app where things are stored.
In CampApp for example there is routing/session configuration of stateful & model/database configuration of stateful. It makes sense have these separated and easily spotted in code, for which use-case object has been intended to be used.
So if, there is a restricted mode, of Stateful, that would allow to serialise ONLY classes that implements some kind of (marker) interface, it would prevent you to accidentally serialising something, what was intended to be serialised elsewhere and then assuming that something is not used.
Currently this behaviour can be simulated using External serialises, which is very impractical.https://gitlab.grifart.cz/grifart/scaffolder/-/issues/30Apply "Preserve" also to properties2023-01-26T10:36:58ZDaniel Kurowskidaniel.kurowski@grifart.czApply "Preserve" also to propertiesThis constructor may not be ideal, but is perfectly valid:
```php
public readonly int $someCount;
public function __construct(
public readonly array $someArray,
) {
$someCount = 0;
foreach ($this->someArray as $someItem) {
// some...This constructor may not be ideal, but is perfectly valid:
```php
public readonly int $someCount;
public function __construct(
public readonly array $someArray,
) {
$someCount = 0;
foreach ($this->someArray as $someItem) {
// some logic which adds to $someCount
}
$this->someCount = $someCount;
}
```
Of course, with `constructorWithPromotedProperties()` this is not possible. However, if I `#[Preserve]` the constructor, the `$someCount` definition is lost.
`#[Preserve]` attribute has a potential to be used to more than methods. I suggest to apply it on properties as well.https://gitlab.grifart.cz/grifart/tables/-/issues/28Validace typů – runtime v PHP nebo v databázi?2023-01-13T10:04:47ZJan Kuchařhonza.kuchar@grifart.czValidace typů – runtime v PHP nebo v databázi?[discussion](https://gitlab.grifart.cz/grifart/tables/-/merge_requests/40#note_99058)
---
# Typová validace na úrovní Typu v Tables
Když mám `IntType::integer()` dává smysl validovat, že je hodnota "správně velká". Ty duplikuji logiku...[discussion](https://gitlab.grifart.cz/grifart/tables/-/merge_requests/40#note_99058)
---
# Typová validace na úrovní Typu v Tables
Když mám `IntType::integer()` dává smysl validovat, že je hodnota "správně velká". Ty duplikuji logiku – pravidla, které má PostgreSQL.
# Typová validace na úrovni databáze
nebo alternativní přístup je i triviálních typů uvádět explictní databázový typ. Pak to padne i v případně, že provedu třeba jen `SELECT 9999999999999999999999999999999999999999::integer`, protože se to do typu nevejde. [ref](https://gitlab.grifart.cz/grifart/tables/-/merge_requests/40#note_97625)https://gitlab.grifart.cz/grifart/tables/-/issues/27TypeSystem: There should be explicitly written that composite/array types acc...2022-11-11T18:27:29ZJan Kuchařhonza.kuchar@grifart.czTypeSystem: There should be explicitly written that composite/array types accepts NULLs everywhereThe following discussion from !40 should be addressed:
- [ ] @jkuchar1, @jpudil started a [discussion](https://gitlab.grifart.cz/grifart/tables/-/merge_requests/40#note_97018): (+1 comment)
> There is implicit support for nullabl...The following discussion from !40 should be addressed:
- [ ] @jkuchar1, @jpudil started a [discussion](https://gitlab.grifart.cz/grifart/tables/-/merge_requests/40#note_97018): (+1 comment)
> There is implicit support for nullable types, shouldn't it be explicit instead?https://gitlab.grifart.cz/grifart/tables/-/issues/24Table::save() does not expose GivenSearchCriteriaHaveNotMatchedAnyRows except...2024-03-21T15:24:00ZJan Kuchařhonza.kuchar@grifart.czTable::save() does not expose GivenSearchCriteriaHaveNotMatchedAnyRows exception in generated classhttps://gitlab.grifart.cz/grifart/scaffolder/-/issues/28ConstantStringType2022-06-22T11:55:08ZJan Kuchařhonza.kuchar@grifart.czConstantStringTypeUse-case: https://gitlab.grifart.cz/CampApp/CampApp/-/merge_requests/1194#note_93313Use-case: https://gitlab.grifart.cz/CampApp/CampApp/-/merge_requests/1194#note_93313Jiří Pudilme@jiripudil.czJiří Pudilme@jiripudil.czhttps://gitlab.grifart.cz/grifart/tables/-/issues/23Generating read models for arbitrary queries / views2023-01-16T09:54:57ZJan Kuchařhonza.kuchar@grifart.czGenerating read models for arbitrary queries / viewsPostgreSQL database is very powerful. Why not to use full power of SQL queries?
...but nodody wants to map each time all columns. We want to get proper data types, right from database...
Let's say we have complex SQL read query. What i...PostgreSQL database is very powerful. Why not to use full power of SQL queries?
...but nodody wants to map each time all columns. We want to get proper data types, right from database...
Let's say we have complex SQL read query. What is the missing parts is strictly typed representation of row of that query and some kind of data mapper.
----
Stretch goal would be to make support also for parameters. This would make `.sql` files more powerful ten using views.
----
Current workaround could be to build view from query we want to read from and continue with standard table generation procedure.https://gitlab.grifart.cz/grifart/stateful/-/issues/14State#getClassName() should return class-string instead of string2022-03-17T16:35:47ZDaniel Kurowskidaniel.kurowski@grifart.czState#getClassName() should return class-string instead of stringhttps://gitlab.grifart.cz/grifart/tables/-/issues/19Better error handling2021-12-29T13:48:50ZJan Kuchařhonza.kuchar@grifart.czBetter error handlingPokrýt možnost chytat výjimky pro:
- checks
- (unique) constraints
- domain types
Nápad: Co kdybychom tyto výjimky anotovali je nu tabulek, kde tyto chyby opravdu mohou nastat?Pokrýt možnost chytat výjimky pro:
- checks
- (unique) constraints
- domain types
Nápad: Co kdybychom tyto výjimky anotovali je nu tabulek, kde tyto chyby opravdu mohou nastat?https://gitlab.grifart.cz/grifart/scaffolder/-/issues/25Release 1.0.0-beta12022-08-30T09:55:36ZJan Kuchařhonza.kuchar@grifart.czRelease 1.0.0-beta1Jiří Pudilme@jiripudil.czJiří Pudilme@jiripudil.czhttps://gitlab.grifart.cz/grifart/stateful/-/issues/13Missing exceptions annotation on serialization (toPayload)2021-11-15T10:23:45ZDaniel Kurowskidaniel.kurowski@grifart.czMissing exceptions annotation on serialization (toPayload)There are plenty exceptions that can be thrown but none are annotated.There are plenty exceptions that can be thrown but none are annotated.https://gitlab.grifart.cz/grifart/scaffolder/-/issues/24Docs: add ref to grifart/tables once it is public2021-10-05T08:57:18ZDaniel Kurowskidaniel.kurowski@grifart.czDocs: add ref to grifart/tables once it is publicAs an example of advanced scaffoldingAs an example of advanced scaffoldinghttps://gitlab.grifart.cz/grifart/tables/-/issues/14API pro kopírování?2023-06-02T16:08:57ZJiří Pudilme@jiripudil.czAPI pro kopírování?Viz https://gitlab.grifart.cz/ivy/server/-/merge_requests/338#note_82517, zakládám issue, ať to v ivy můžu zavřít, aniž by to zapadlo.
@jkuchar1:
> Tady na ty kopírování mezi tabulkami by asi dávalo smysl časem něco přidat do tables, c...Viz https://gitlab.grifart.cz/ivy/server/-/merge_requests/338#note_82517, zakládám issue, ať to v ivy můžu zavřít, aniž by to zapadlo.
@jkuchar1:
> Tady na ty kopírování mezi tabulkami by asi dávalo smysl časem něco přidat do tables, co myslíš? :-) Že by člověk jen nahodil co na co a WHERE a hotovo. I když přidaná hodnota, není zase tak velká. Chtělo by to udělat nějak šikovně tak, aby to vyřešil ten typový problém, že třeba chybí povinný sloupec.
@jpudil
> Hm, to bude obtížné navrhnout dostatečně obecně - kupříkladu při publikaci se vkládá naopak než tady a přidává se tam napevno versionNumber právě publikované verze.https://gitlab.grifart.cz/grifart/scaffolder/-/issues/21Nullable values & named constructors2021-07-16T08:42:47ZJan Kuchařhonza.kuchar@grifart.czNullable values & named constructorse.g.
```php
PrefilledValues::from(
emailAddress: null,
name: null,
language: 'cs',
gender: null,
);
```
Jde o to, aby bylo možné vyplnit jen některé parametry. Tj. jedná se o to, že chybí `null` parametrů výchozí hodnota `= nu...e.g.
```php
PrefilledValues::from(
emailAddress: null,
name: null,
language: 'cs',
gender: null,
);
```
Jde o to, aby bylo možné vyplnit jen některé parametry. Tj. jedná se o to, že chybí `null` parametrů výchozí hodnota `= null`, takže je nelze přeskočit.
Navrhuji `MakeNullableParametersOptionalDecorator($methodName)`.
---------------
The following discussion from CampApp/CampApp!1023 should be addressed:
- [ ] @jkuchar1 started a [discussion](https://gitlab.grifart.cz/CampApp/CampApp/-/merge_requests/1023#note_82362): (+5 comments)
> Toto nechápu, vždyť jsou nullable již každý parametr samostatně, takže by měly být nullable i konstruktor parametry. Ne?https://gitlab.grifart.cz/grifart/tables/-/issues/11Check type's default value in addition to column's default?2021-01-11T16:46:44ZJiří Pudilme@jiripudil.czCheck type's default value in addition to column's default?Follow-up from https://gitlab.grifart.cz/grifart/tables/-/merge_requests/8#note_77803Follow-up from https://gitlab.grifart.cz/grifart/tables/-/merge_requests/8#note_77803https://gitlab.grifart.cz/grifart/stateful/-/issues/10MatchMapper: throw an exception on abstract class or interface2020-10-19T12:34:25ZDaniel Kurowskidaniel.kurowski@grifart.czMatchMapper: throw an exception on abstract class or interfaceWhen I use `VersionIdentifier::class` which is an abstract class, mapper does not tell me I should not do it and I have a bug as inheritors of such class do not get serialized.When I use `VersionIdentifier::class` which is an abstract class, mapper does not tell me I should not do it and I have a bug as inheritors of such class do not get serialized.https://gitlab.grifart.cz/grifart/stateful/-/issues/8Generický State2020-12-01T15:17:00ZJiří Pudilme@jiripudil.czGenerický StateThe following discussion from !20 should be addressed:
- [ ] @jkuchar1 started a [discussion](https://gitlab.grifart.cz/grifart-internal/stateful/-/merge_requests/20#note_74913):
> Možná raději genericky?
@jpudil replied:
...The following discussion from !20 should be addressed:
- [ ] @jkuchar1 started a [discussion](https://gitlab.grifart.cz/grifart-internal/stateful/-/merge_requests/20#note_74913):
> Možná raději genericky?
@jpudil replied:
> U interního Payloadu v tom nevidím přínos; když už generika, tak u `State`, ale to nebude tak jednoduché, klidně bych z toho udělal samostatné issuehttps://gitlab.grifart.cz/grifart/stateful/-/issues/6Readme: elaborate mappers2020-10-06T12:32:48ZDaniel Kurowskidaniel.kurowski@grifart.czReadme: elaborate mappersCurrently, CampApp config is as crazy as:
![image](/uploads/55fca0c21785735fb0bc37961eaced7e/image.png)
But there is almost no word about how to use these `*Mapper` things even they are part of this library.Currently, CampApp config is as crazy as:
![image](/uploads/55fca0c21785735fb0bc37961eaced7e/image.png)
But there is almost no word about how to use these `*Mapper` things even they are part of this library.