The issue like that: https://github.com/yiisoft/yii2/issues/10969
If "defaultValue" contains comma, incorrect code will be generated.
yii migrate/create add_field_to_table
--fields="title:string(10):notNull:unique:defaultValue('te,st'),body:text:notNull"
Confirmed. Would you like to fix the regexp and submit a PR?
@s-o-f @SilverFire i can handle it ;)
@s-o-f @s1lver check my pr please https://github.com/yiisoft/yii2/pull/11463
@pana1990
Not worked with
defaultValue('te,s,t')
and
defaultValue( 'te,s,t' ) whitespaces between "(" and '
also
defaultValue(',')
Some tests: https://regex101.com/r/gZ5dH3/1
ups, its true, any suggestion?
Maybe something like this:
(?!\((\'|")*[^"\']+)\s*,\s*(?![^"\']*(\'|")*\))
Tests: https://regex101.com/r/gZ5dH3/2
UPD: not working(
@s-o-f try it this one, please :
(?!\((\'|")*[^"\']+)\s*,\s*((?![^"\'(\)]*(\'|")*\)))
Last two lines fails
https://regex101.com/r/gZ5dH3/5
yes, let's me try again.
@pana1990
Your last variant fails at last line here: https://regex101.com/r/gZ5dH3/8
How about this: (?!\([^\s*\,])\s*,\s*(?!.*('|")\))
https://regex101.com/r/gZ5dH3/9
@s-o-f it fails in the following example :
< sdfsf,sdfsdf,asdsd(),sdfsdf('3',33,"22"), > without end line.
we should use https://regex101.com/ before making more commits. That way everyone can test the provided regex easily
@pana1990
Maybe this: (?!\([^\s*\,])\s*,\s*(?![^"']*('|")\))
https://regex101.com/r/gZ5dH3/11
In this sdfsdf('3',33, "22") you can't use ' and ", then migrate command will be invalid:
yii migrate/create add_field_to_table
--fields="title:string(10):notNull:unique:defaultValue('3',33, "22"),body:text:notNull"
Huh, not so easy :laughing:
The last one seems to be correct.
In this sdfsdf('3',33, "22") you can't use ' and "
It's a kind of shooting yourself in the foot. Don't take care too much about this case :)
@s-o-f
this example fails :
title:string(10):notNull:unique:defaultValue("test"),body:text:notNull,price:money(11,2):notNull
@s-o-f @SilverFire
I thingk to find to solution :
\s*,\s*(?![^()]*\))
https://regex101.com/r/gZ5dH3/14
are there other case where it can fail?
```
i think it is okey, can you check it? @s-o-f @SilverFire
thanks in advanced