PhilWaldmann / openrecord

Make ORMs great again!
https://openrecord.js.org
MIT License
486 stars 38 forks source link

Allow column params to be passed to knex #92

Closed shreeve closed 5 years ago

shreeve commented 5 years ago

This is needed to be able to pass params such as the length of a varchar column. Otherwise, the defaults of varchar(255), etc. will always be used.

db bash 2019-02-14 03-11-52
PhilWaldmann commented 5 years ago

Hi Steve,

thank your very much. Would you mind adding some tests?

shreeve commented 5 years ago

I'll add some tests and documentation to this. Hopefully, these few tweaks allow a much more fluid way to do migrations.

shreeve commented 5 years ago

image

shreeve commented 5 years ago

Check was showing as failing, but I closed and re-opened this PR to force Travis to re-run, and it succeeded. Hrm...

I'll work on specific tests now for this PR.

shreeve commented 5 years ago

@PhilWaldmann - I've added two test files, but am not quite sure how to get them to run properly. Could you take a quick look?

PhilWaldmann commented 5 years ago

I‘m currenlty on the go, but I‘ll check your tests in the evening.

Thanks, Philipp

PhilWaldmann commented 5 years ago

One way would be to query the database and check the database types.

But a nicer solution would be to add the additional length information to the field (see attributes.js

The postgres driver currently reads the length information and adds a validatesLengthOf validation. Something the mysql and sqlite driver are not doing. This should be unified anyways.

PhilWaldmann commented 5 years ago

Do you need further assistance with this PR?