UUID instead of an auto-increment integer for ID with Active Record

Comparing #1 with #2

Revision #2 was created by grigori grigori on Nov 25, 2019, 10:12:48 PM.

fixing the markup

Tags

mysql,active record,REST,UUID

Content

[...]
}],
```
These filters will validate input, prepare UUID to be written in a binary format and keep the text form for output.

3. Add getters

 
```
public function __get($name)
{
[...]
return $this->idText ?? $this->getAttribute('id_text');
}

 
```
 
Active Record does not call the getter method if attributes contain the property. It should not be this way, so I return the default component behavior and make ID returned the right way.
From the other hand, the first valiator calls `$model->id` triggering the getter before the UUID is saved to the private property so I need to serve the value from user input.
[...]
So, now you can go the generic mysql way
4. add a virtual column

 
```
ALTER TABLE t1 ADD id_text varchar(36) generated always as
(insert(
[...]
24,0,'-')
) virtual;
 
 
```