Skip to content
This repository has been archived by the owner on Jun 4, 2024. It is now read-only.

List of general enhancements #122

Open
2 of 6 tasks
SOHELAHMED7 opened this issue Dec 23, 2022 · 4 comments
Open
2 of 6 tasks

List of general enhancements #122

SOHELAHMED7 opened this issue Dec 23, 2022 · 4 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@SOHELAHMED7
Copy link
Contributor

SOHELAHMED7 commented Dec 23, 2022

  • enum for PGSQL should be rename to enum_<TABLE_NAME>_<COLUMN_NAME> instead of current enum_<COLUMN_NAME>
  • change in Enum values (rename, add, drop values) - alter column. Enum column once created, it is not very simple to edit existing enum values, re-order it, add new enum values in between, drop in-between enum values. E.g. if ENUM(TELEVISION, CELL, LAPTOP) needed to be changed to ENUM(MOBILE, COMPUTER, TV) then it cannot be done in single SQL statement
  • default value by constant and expression in CRUD, models, faker, controllers etc parts. If x-db-default-expression is present then ensure it is present in \yii\db\Expression(...) in model validation rules()
  • alter the column position migration generation in MySQL and MariaDB if a field position(of existing field/column) is changed in YAML. If a column position is changed in OpenAPI and nothing else then its MySQL/Maria migration should be generated to alter column position
  • Enhance all code generation for x-db-type Enhance all code generation for x-db-type #119 . E.g. x-db-type should be reflected in model validation rules() + faker and other place where relevant. PR: Resolve - Consider x-db-type in validation rules and faker and more if any SOHELAHMED7/yii2-openapi#17
  • alter column data type by just x-db-default-expression change (this can be fixed if upstream issue Default expression is not loaded into ColumnSchema yiisoft/yii2#19747 is fixed)
@cebe
Copy link
Owner

cebe commented Jan 27, 2023

@SOHELAHMED7 as far as I see some of these are already done. Please update the checkbox list.

@SOHELAHMED7
Copy link
Contributor Author

No. Only first one is completed and that is already checked. Though this is none of your fault, I have described in very short detail. I am elaborating it soon

@SOHELAHMED7
Copy link
Contributor Author

I have provided more detail to each checkbox. One was duplicate so removed it. Each checkbox task is big enough such that it should have stand alone issue. But instead I have kept this as list because I think it comes under "nice to have", "later" or "low priority" status

If you feel any one of these deserve high priority, please let me know

@SOHELAHMED7
Copy link
Contributor Author

@cebe

Regarding task: Enhance all code generation for x-db-type #119 . E.g. x-db-type should be reflected in model validation rules() + faker and other place where relevant. (SOHELAHMED7#17)

I am generating models with default value and validation rules obtained from OpenAPI spec.

Ideally fake values generated by faker should pass validation.

This happens in all cases except MySQL datetime data type.

Consider

datetime_col:
          type: string
          x-db-type: datetime

generates models validation rules:

'datetime_col_datetime' => [['datetime_col'], 'datetime', 'format' => '-----THIS is WIP ---'  ],
// more about format is described below

and faker

$model->datetime_col = $faker->dateTimeThisYear('now', 'UTC')->format(DATE_ATOM);
format

if format is 'php:c' (which represents DATE_ATOM), validation fails. Please see yiisoft/yii2#19754.

Also generating model validation code as

`format` => 'php:'.DATE_ATOM

is difficult because we use VarDumper::export() which return the string along with quotes

Also if I pass value of DATE_ATOM then Y-m-d\TH:i:sP is converted to Y-m-d\\\\TH:i:sP in model validation rules() code that also fails validation

So I am changed format in faker from DATE_ATOM to Y-m-d H:i:s to make validation pass for the faked value.

If you have hint for solution for above problems please share.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
Status: 📋 Backlog
Development

No branches or pull requests

2 participants