cycle / annotated

Schema generation using annotated entities and mappers
MIT License
23 stars 12 forks source link

It would be nice to be able to define charsets for columns like this: #59

Open roxblnfk opened 1 year ago

roxblnfk commented 1 year ago

It would be nice to be able to define charsets for columns like this:

#[Entity]
class User
{
    #[Column(type: 'primary')]
    private int $id;

    #[Column(type: 'string', name: 'username', charset: 'latin1', collation: 'latin1_bin')]
    private string $email;
}

Originally posted by @ardabeyazoglu in https://github.com/cycle/orm/discussions/370

ardabeyazoglu commented 1 year ago

There can be columns with different charsets for both performance reasons and limitations. For example you cant index 255 char utf8mb4 column, but you could do it with latin1. Email is a good example

roxblnfk commented 1 year ago

I think it possible using custom typecast handler. It won't work with migration generator but in PHP you will always work with UTF-8

ardabeyazoglu commented 1 year ago

Php is not problem here anyway. But people who create schemas and migrations using the orm, might need it to prevent manual tricks. If it is possible using typecast handler, then there is no issue at all. Thanks for answering.

ardabeyazoglu commented 1 year ago

The actual implementation of annotation is here: https://github.com/cycle/annotated/blob/3.x/src/Annotation/Column.php Should I create another issue there as well or you manage anything related from here ?

roxblnfk commented 1 year ago

You are right.

or you manage anything related from here

I do it from here :)